Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkItkImageIO.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkItkImageIO_h
14 #define mitkItkImageIO_h
15 
16 #include <mitkAbstractFileIO.h>
17 #include <mitkImage.h>
18 #include <itkImageIOBase.h>
19 
20 namespace mitk
21 {
35  {
36  public:
42  ItkImageIO(itk::ImageIOBase::Pointer imageIO);
43 
51  ItkImageIO(const CustomMimeType &mimeType, itk::ImageIOBase::Pointer imageIO, int rank);
52 
53  // -------------- AbstractFileReader -------------
54 
56 
59 
60  // -------------- AbstractFileWriter -------------
61 
63  void Write() override;
64 
67 
81  static PropertyList::Pointer ExtractMetaDataAsPropertyList(const itk::MetaDataDictionary& dictionary, const std::string& mimeTypeName, const std::vector<std::string>& defaultMetaDataKeys);
82 
92  static Image::Pointer LoadRawMitkImageFromImageIO(itk::ImageIOBase* imageIO, const std::string& path);
93 
100  static void PreparImageIOToWriteImage(itk::ImageIOBase* imageIO, const Image* image);
101 
109  static void SavePropertyListAsMetaData(itk::MetaDataDictionary& dictionary, const PropertyList* properties, const std::string& mimeTypeName);
110 
111 
112  protected:
119  virtual std::vector<std::string> FixUpImageIOExtensions(const std::string &imageIOName);
120 
127  virtual void FixUpCustomMimeTypeName(const std::string &imageIOName, CustomMimeType &customMimeType);
128 
131 
132  // -------------- AbstractFileReader -------------
133  std::vector<itk::SmartPointer<BaseData>> DoRead() override;
134 
135  private:
136  ItkImageIO(const ItkImageIO &other);
137 
138  ItkImageIO *IOClone() const override;
139 
140  itk::ImageIOBase::Pointer m_ImageIO;
141 
142  std::vector<std::string> m_DefaultMetaDataKeys;
143  };
144 
147  MITKCORE_EXPORT std::vector<TimePointType> ConvertMetaDataObjectToTimePointList(const itk::MetaDataObjectBase* data);
148 
149 
153  MITKCORE_EXPORT itk::MetaDataObjectBase::Pointer ConvertTimePointListToMetaDataObject(const mitk::TimeGeometry* timeGeometry);
154 
155 } // namespace mitk
156 
157 #endif
#define MITKCORE_EXPORT
Abstract base class for implementing a combined file reader and writer.
std::vector< itk::SmartPointer< BaseData > > Read() override
Read data and create a list of BaseData objects.
A custom mime-type that can be registered as a service object.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Wraps ITK image IO objects as mitk::IFileReader and mitk::IFileWriter objects.
virtual void FixUpCustomMimeTypeName(const std::string &imageIOName, CustomMimeType &customMimeType)
Fix up the custom MIME type name based on the ITK ImageIO name.
ItkImageIO(itk::ImageIOBase::Pointer imageIO)
Construct an ItkImageIO from an ITK ImageIO instance.
static Image::Pointer LoadRawMitkImageFromImageIO(itk::ImageIOBase *imageIO, const std::string &path)
Extract a raw MITK image from the given file path using the specified ImageIOBase.
ConfidenceLevel GetReaderConfidenceLevel() const override
Get the confidence level for reading the current file.
static void PreparImageIOToWriteImage(itk::ImageIOBase *imageIO, const Image *image)
Prepare an ITK ImageIOBase instance for writing the given MITK image.
static void SavePropertyListAsMetaData(itk::MetaDataDictionary &dictionary, const PropertyList *properties, const std::string &mimeTypeName)
Save a PropertyList as meta data in an ITK MetaDataDictionary.
void Write() override
Write the input data to file.
ItkImageIO(const CustomMimeType &mimeType, itk::ImageIOBase::Pointer imageIO, int rank)
Construct an ItkImageIO with a custom MIME type and rank.
virtual void InitializeDefaultMetaDataKeys()
Fills the m_DefaultMetaDataKeys vector with default values.
std::vector< itk::SmartPointer< BaseData > > DoRead() override
Perform the actual reading operation.
static PropertyList::Pointer ExtractMetaDataAsPropertyList(const itk::MetaDataDictionary &dictionary, const std::string &mimeTypeName, const std::vector< std::string > &defaultMetaDataKeys)
Convert a MetaDataDictionary into a PropertyList for a certain MIME type.
virtual std::vector< std::string > FixUpImageIOExtensions(const std::string &imageIOName)
Fix up file extensions reported by the ITK ImageIO.
ConfidenceLevel GetWriterConfidenceLevel() const override
Get the confidence level for writing the current data.
Key-value list holding instances of BaseProperty.
Find image slices visible on a given plane.
MITKCORE_EXPORT itk::MetaDataObjectBase::Pointer ConvertTimePointListToMetaDataObject(const mitk::TimeGeometry *timeGeometry)
MITKCORE_EXPORT std::vector< TimePointType > ConvertMetaDataObjectToTimePointList(const itk::MetaDataObjectBase *data)
ConfidenceLevel
A confidence level describing the reader's or writer's ability to handle the given data or file forma...
Definition: mitkIFileIO.h:57