21 #include <itkImageFileReader.h>
22 #include <itkRawImageIO.h>
38 m_Dimensions[i] = dim;
46 return m_Dimensions[i];
50 const std::string filePrefix,
51 const std::string filePattern)
58 if (filePattern !=
"" && filePrefix !=
"")
68 if (this->GetOutput() ==
nullptr)
76 itkWarningMacro(<<
"File Type not supported!");
81 if (m_Dimensionality == 2)
83 if (m_PixelType == SCHAR)
84 TypedGenerateData<signed char, 2>();
85 else if (m_PixelType == UCHAR)
86 TypedGenerateData<unsigned char, 2>();
87 else if (m_PixelType == SSHORT)
88 TypedGenerateData<signed short int, 2>();
89 else if (m_PixelType == USHORT)
90 TypedGenerateData<unsigned short int, 2>();
91 else if (m_PixelType == UINT)
92 TypedGenerateData<unsigned int, 2>();
93 else if (m_PixelType == SINT)
94 TypedGenerateData<signed int, 2>();
95 else if (m_PixelType == FLOAT)
96 TypedGenerateData<float, 2>();
97 else if (m_PixelType == DOUBLE)
98 TypedGenerateData<double, 2>();
101 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set"
106 else if (m_Dimensionality == 3)
108 if (m_PixelType == SCHAR)
109 TypedGenerateData<signed char, 3>();
110 else if (m_PixelType == UCHAR)
111 TypedGenerateData<unsigned char, 3>();
112 else if (m_PixelType == SSHORT)
113 TypedGenerateData<signed short int, 3>();
114 else if (m_PixelType == USHORT)
115 TypedGenerateData<unsigned short int, 3>();
116 else if (m_PixelType == UINT)
117 TypedGenerateData<unsigned int, 3>();
118 else if (m_PixelType == SINT)
119 TypedGenerateData<signed int, 3>();
120 else if (m_PixelType == FLOAT)
121 TypedGenerateData<float, 3>();
122 else if (m_PixelType == DOUBLE)
123 TypedGenerateData<double, 3>();
126 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set"
133 MITK_INFO <<
"Error while reading raw file: Dimensionality not supported" << std::endl;
137 MITK_INFO <<
"...reading raw finished!" << std::endl;
140 template <
typename TPixel,
unsigned int VImageDimensions>
145 if (this->GetOutput() ==
nullptr)
150 MITK_INFO <<
"loading " << m_FileName <<
" via itk::ImageIOFactory... " << std::endl;
153 if (m_FileName ==
"")
155 itkWarningMacro(<<
"File Type not supported!");
159 typedef itk::Image<TPixel, VImageDimensions>
ImageType;
160 typedef itk::ImageFileReader<ImageType> ReaderType;
161 typedef itk::RawImageIO<TPixel, VImageDimensions> IOType;
166 io->SetFileDimensionality(VImageDimensions);
168 for (
unsigned short int dim = 0; dim < VImageDimensions; ++dim)
170 io->SetDimensions(dim, m_Dimensions[dim]);
173 if (m_Endianity == LITTLE)
175 io->SetByteOrderToLittleEndian();
177 else if (m_Endianity == BIG)
179 io->SetByteOrderToBigEndian();
183 MITK_INFO <<
"Warning: endianity not properly set. Resulting image might be incorrect";
186 reader->SetImageIO(io);
187 reader->SetFileName(m_FileName.c_str());
193 catch (itk::ExceptionObject &err)
195 MITK_ERROR <<
"An error occurred during the raw image reading process: ";
201 output->Initialize(image);
202 output->SetVolume(reader->GetOutput()->GetBufferPointer());
itk::SmartPointer< Self > Pointer
void SetDimensions(unsigned int i, unsigned int dim)
static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
unsigned int GetDimensions(unsigned int i) const
map::core::discrete::Elements< 3 >::InternalImageType ImageType
static const std::string filename
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.