24 #include <itkImageFileReader.h>
25 #include <itkRawImageIO.h>
34 std::vector<std::string> pixelEnum;
46 std::vector<std::string> dimEnum;
47 dimEnum.push_back(
"2");
48 dimEnum.push_back(
"3");
52 std::vector<std::string> endianEnum;
74 std::vector<mitk::BaseData::Pointer> result;
76 const std::string path = this->GetLocalFileName();
78 const Options options = this->GetOptions();
92 if (dimensionality ==
"2")
95 result.push_back(TypedRead<signed char, 2>(path, endianity, dimensions));
97 result.push_back(TypedRead<unsigned char, 2>(path, endianity, dimensions));
99 result.push_back(TypedRead<signed short int, 2>(path, endianity, dimensions));
101 result.push_back(TypedRead<unsigned short int, 2>(path, endianity, dimensions));
103 result.push_back(TypedRead<unsigned int, 2>(path, endianity, dimensions));
105 result.push_back(TypedRead<signed int, 2>(path, endianity, dimensions));
107 result.push_back(TypedRead<float, 2>(path, endianity, dimensions));
109 result.push_back(TypedRead<double, 2>(path, endianity, dimensions));
112 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set"
116 else if (dimensionality ==
"3")
119 result.push_back(TypedRead<signed char, 3>(path, endianity, dimensions));
121 result.push_back(TypedRead<unsigned char, 3>(path, endianity, dimensions));
123 result.push_back(TypedRead<signed short int, 3>(path, endianity, dimensions));
125 result.push_back(TypedRead<unsigned short int, 3>(path, endianity, dimensions));
127 result.push_back(TypedRead<unsigned int, 3>(path, endianity, dimensions));
129 result.push_back(TypedRead<signed int, 3>(path, endianity, dimensions));
131 result.push_back(TypedRead<float, 3>(path, endianity, dimensions));
133 result.push_back(TypedRead<double, 3>(path, endianity, dimensions));
136 MITK_INFO <<
"Error while reading raw file: Dimensionality or pixel type not supported or not properly set"
142 MITK_INFO <<
"Error while reading raw file: Dimensionality not supported" << std::endl;
148 template <
typename TPixel,
unsigned int VImageDimensions>
150 EndianityType endianity,
153 typedef itk::Image<TPixel, VImageDimensions>
ImageType;
154 typedef itk::ImageFileReader<ImageType> ReaderType;
155 typedef itk::RawImageIO<TPixel, VImageDimensions> IOType;
160 io->SetFileDimensionality(VImageDimensions);
162 for (
unsigned short int dim = 0; dim < VImageDimensions; ++dim)
164 io->SetDimensions(dim, size[dim]);
167 if (endianity == LITTLE)
169 io->SetByteOrderToLittleEndian();
171 else if (endianity == BIG)
173 io->SetByteOrderToBigEndian();
177 MITK_INFO <<
"Warning: endianity not properly set. Resulting image might be incorrect";
180 reader->SetImageIO(io);
181 reader->SetFileName(path);
187 catch (itk::ExceptionObject &err)
189 MITK_ERROR <<
"An error occurred during the raw image reading process: ";
195 image->SetVolume(reader->GetOutput()->GetBufferPointer());
196 return image.GetPointer();
201 return new RawImageFileReaderService(*
this);
itk::SmartPointer< Self > Pointer
static std::string PIXEL_TYPE_USHORT()
static std::string PIXEL_TYPE_DOUBLE()
static std::string DIMENSION_ENUM()
static std::string ENDIANNESS_ENUM()
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > Options
Options for reading or writing data.
static std::string PIXEL_TYPE_CHAR()
static std::string ENDIANNESS_BIG()
static std::string SIZE_Z()
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
static std::string PIXEL_TYPE_UINT()
map::core::discrete::Elements< 3 >::InternalImageType ImageType
void SetDefaultOptions(const Options &defaultOptions)
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static std::string PIXEL_TYPE_INT()
static std::string DIMENSION()
static std::string SIZE_X()
static std::string ENDIANNESS_LITTLE()
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
RawImageFileReaderService()
Base class for creating mitk::BaseData objects from files or streams.
static std::string PIXEL_TYPE_SHORT()
static std::string ENDIANNESS()
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
static std::string PIXEL_TYPE_FLOAT()
static std::string SIZE_Y()
static std::string PIXEL_TYPE_UCHAR()
static std::string PIXEL_TYPE_ENUM()
static std::string PIXEL_TYPE()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.