ITK  6.0.0
Insight Toolkit
itkGDCMImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkGDCMImageIO_h
29 #define itkGDCMImageIO_h
30 
31 #include "itkCommonEnums.h"
32 #include "itkImageIOBase.h"
33 #include "ITKIOGDCMExport.h"
34 #include <fstream>
35 #include <string>
36 
37 
38 namespace itk
39 {
44 {
45 public:
50  enum class Compression : uint8_t
51  {
52  JPEG = 0,
53  JPEG2000,
54  JPEGLS,
55  RLE
56  };
57 };
58 
59 // Define how to print enumeration
60 extern ITKIOGDCM_EXPORT std::ostream &
61  operator<<(std::ostream & out, const GDCMImageIOEnums::Compression value);
102 class InternalHeader;
103 class ITKIOGDCM_EXPORT GDCMImageIO : public ImageIOBase
104 {
105 public:
106  ITK_DISALLOW_COPY_AND_MOVE(GDCMImageIO);
110  using Self = GDCMImageIO;
113 
115  itkNewMacro(Self);
116 
118  itkOverrideGetNameOfClassMacro(GDCMImageIO);
119 
120  /*-------- This part of the interface deals with reading data. ------ */
121 
124  bool
125  CanReadFile(const char *) override;
126 
128  void
129  ReadImageInformation() override;
130 
132  void
133  Read(void * pointer) override;
134 
138  itkGetEnumMacro(InternalComponentType, itk::CommonEnums::IOComponent);
139  itkSetEnumMacro(InternalComponentType, itk::CommonEnums::IOComponent);
142  /*-------- This part of the interfaces deals with writing data. ----- */
143 
146  bool
147  CanWriteFile(const char *) override;
148 
151  void
152  WriteImageInformation() override;
153 
156  void
157  Write(const void * buffer) override;
158 
160  itkGetConstMacro(RescaleSlope, double);
161  itkGetConstMacro(RescaleIntercept, double);
167  itkGetStringMacro(UIDPrefix);
168  itkSetStringMacro(UIDPrefix);
172  itkGetStringMacro(StudyInstanceUID);
173  itkGetStringMacro(SeriesInstanceUID);
174  itkGetStringMacro(FrameOfReferenceInstanceUID);
178  itkSetMacro(KeepOriginalUID, bool);
179  itkGetConstMacro(KeepOriginalUID, bool);
180  itkBooleanMacro(KeepOriginalUID);
185  itkSetMacro(LoadPrivateTags, bool);
186  itkGetConstMacro(LoadPrivateTags, bool);
187  itkBooleanMacro(LoadPrivateTags);
192  itkSetMacro(ReadYBRtoRGB, bool);
193  itkGetConstMacro(ReadYBRtoRGB, bool);
194  itkBooleanMacro(ReadYBRtoRGB);
199  bool
200  GetValueFromTag(const std::string & tag, std::string & value);
201 
208  static bool
209  GetLabelFromTag(const std::string & tag, std::string & labelId);
210 
212 #if !defined(ITK_LEGACY_REMOVE)
213  // We need to expose the enum values at the class level
214  // for backwards compatibility
215  static constexpr CompressionEnum JPEG = CompressionEnum::JPEG;
216  static constexpr CompressionEnum JPEG2000 = CompressionEnum::JPEG2000;
217  static constexpr CompressionEnum JPEGLS = CompressionEnum::JPEGLS;
218  static constexpr CompressionEnum RLE = CompressionEnum::RLE;
219 #endif
220 
221  itkSetEnumMacro(CompressionType, CompressionEnum);
222  itkGetEnumMacro(CompressionType, CompressionEnum);
223 
224  void
225  InternalSetCompressor(const std::string & _compressor) override;
226 
227 protected:
228  GDCMImageIO();
229  ~GDCMImageIO() override;
230  void
231  PrintSelf(std::ostream & os, Indent indent) const override;
232 
233  void
234  InternalReadImageInformation();
235 
236  double m_RescaleSlope{};
237 
238  double m_RescaleIntercept{};
239 
240  std::string m_UIDPrefix{};
241 
242  std::string m_StudyInstanceUID{};
243 
244  std::string m_SeriesInstanceUID{};
245 
246  std::string m_FrameOfReferenceInstanceUID{};
247 
248  bool m_KeepOriginalUID{};
249 
250  bool m_LoadPrivateTags{};
251 
252  bool m_ReadYBRtoRGB{};
253 
254 private:
255  unsigned int m_GlobalNumberOfDimensions{};
256 
257  CompressionEnum m_CompressionType{};
258 
259  bool m_SingleBit{};
260 
261  IOComponentEnum m_InternalComponentType{};
262 
263  InternalHeader * m_DICOMHeader{};
264 };
265 
266 } // end namespace itk
267 
268 #endif // itkGDCMImageIO_h
itk::ImageIOBase
Abstract superclass defines image IO interface.
Definition: itkImageIOBase.h:77
itk::GDCMImageIOEnums::Compression
Compression
Definition: itkGDCMImageIO.h:50
itk::GDCMImageIOEnums
Definition: itkGDCMImageIO.h:43
itk::GDCMImageIOEnums::Compression::RLE
itk::operator<<
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::CommonEnums::IOComponent
IOComponent
Definition: itkCommonEnums.h:74
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GDCMImageIOEnums::Compression::JPEGLS
itk::GDCMImageIOEnums::Compression::JPEG2000
itk::GDCMImageIOEnums::Compression::JPEG
itk::GDCMImageIO
ImageIO class for reading and writing DICOM V3.0 and ACR/NEMA 1&2 uncompressed images....
Definition: itkGDCMImageIO.h:103
itkImageIOBase.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkCommonEnums.h
Compression
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61