17 #include <itkImageFileReader.h> 18 #include <itkRawImageIO.h> 46 const std::string filePrefix,
47 const std::string filePattern)
54 if (filePattern !=
"" && filePrefix !=
"")
72 itkWarningMacro(<<
"File Type not supported!");
80 TypedGenerateData<signed char, 2>();
82 TypedGenerateData<unsigned char, 2>();
84 TypedGenerateData<signed short int, 2>();
86 TypedGenerateData<unsigned short int, 2>();
88 TypedGenerateData<unsigned int, 2>();
90 TypedGenerateData<signed int, 2>();
92 TypedGenerateData<float, 2>();
94 TypedGenerateData<double, 2>();
97 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set" 105 TypedGenerateData<signed char, 3>();
107 TypedGenerateData<unsigned char, 3>();
109 TypedGenerateData<signed short int, 3>();
111 TypedGenerateData<unsigned short int, 3>();
113 TypedGenerateData<unsigned int, 3>();
115 TypedGenerateData<signed int, 3>();
117 TypedGenerateData<float, 3>();
119 TypedGenerateData<double, 3>();
122 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set" 129 MITK_INFO <<
"Error while reading raw file: Dimensionality not supported" << std::endl;
133 MITK_INFO <<
"...reading raw finished!" << std::endl;
136 template <
typename TPixel,
unsigned int VImageDimensions>
151 itkWarningMacro(<<
"File Type not supported!");
155 typedef itk::Image<TPixel, VImageDimensions>
ImageType;
156 typedef itk::ImageFileReader<ImageType> ReaderType;
157 typedef itk::RawImageIO<TPixel, VImageDimensions> IOType;
159 typename ReaderType::Pointer reader = ReaderType::New();
160 typename IOType::Pointer io = IOType::New();
162 io->SetFileDimensionality(VImageDimensions);
164 for (
unsigned short int dim = 0; dim < VImageDimensions; ++dim)
171 io->SetByteOrderToLittleEndian();
175 io->SetByteOrderToBigEndian();
179 MITK_INFO <<
"Warning: endianity not properly set. Resulting image might be incorrect";
182 reader->SetImageIO(io);
189 catch (itk::ExceptionObject &err)
191 MITK_ERROR <<
"An error occurred during the raw image reading process: ";
197 output->Initialize(image);
198 output->SetVolume(reader->GetOutput()->GetBufferPointer());
void SetDimensions(unsigned int i, unsigned int dim)
itk::Image< unsigned char, 3 > ImageType
static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
void GenerateData() override
unsigned int GetDimensions(unsigned int i) const
itk::Vector< int, 3 > m_Dimensions
EndianityType m_Endianity
mitk::Image::Pointer image
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
~RawImageFileReader() override
OutputType * GetOutput()
Get the output data of this image source object.