SimpleITK  
sitkImageFileWriter.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  * http://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 #ifndef sitkImageFileWriter_h
19 #define sitkImageFileWriter_h
20 
21 #include "sitkMacro.h"
22 #include "sitkPathType.h"
23 #include "sitkImage.h"
25 #include "sitkIO.h"
26 #include "sitkProcessObject.h"
27 
28 #include <memory>
29 
30 namespace itk
31 {
32 
33 // Forward declaration for pointer
34 class ImageIOBase;
35 
36 template <class T>
37 class SmartPointer;
38 
39 namespace simple
40 {
41 
52 {
53 public:
55 
56  // list of pixel types supported
58 
59  ~ImageFileWriter() override;
60 
62 
64  std::string
65  ToString() const override;
66 
68  std::string
69  GetName() const override
70  {
71  return std::string("ImageFileWriter");
72  }
73 
76  virtual std::vector<std::string>
77  GetRegisteredImageIOs() const;
78 
79 
86  SITK_RETURN_SELF_TYPE_HEADER
87  SetUseCompression(bool UseCompression);
88  bool
89  GetUseCompression() const;
90 
91  SITK_RETURN_SELF_TYPE_HEADER
93  {
94  return this->SetUseCompression(true);
95  }
96  SITK_RETURN_SELF_TYPE_HEADER
98  {
99  return this->SetUseCompression(false);
100  }
110  SITK_RETURN_SELF_TYPE_HEADER
111  SetCompressionLevel(int);
112  int
113  GetCompressionLevel() const;
122  SITK_RETURN_SELF_TYPE_HEADER
123  SetCompressor(const std::string &);
124  std::string
125  GetCompressor();
140  virtual SITK_RETURN_SELF_TYPE_HEADER
141  SetImageIO(const std::string & imageio);
142  virtual std::string
143  GetImageIO() const;
144  /* @} */
145 
146 
155  SITK_RETURN_SELF_TYPE_HEADER
156  SetKeepOriginalImageUID(bool KeepOriginalImageUID);
157  bool
158  GetKeepOriginalImageUID() const;
159 
160  SITK_RETURN_SELF_TYPE_HEADER
162  {
163  return this->SetKeepOriginalImageUID(true);
164  }
165  SITK_RETURN_SELF_TYPE_HEADER
167  {
168  return this->SetKeepOriginalImageUID(false);
169  }
172  SITK_RETURN_SELF_TYPE_HEADER
173  SetFileName(const PathType & fileName);
174  PathType
175  GetFileName() const;
176 
177  SITK_RETURN_SELF_TYPE_HEADER
178  Execute(const Image &);
179  SITK_RETURN_SELF_TYPE_HEADER
180  Execute(const Image &, const PathType & inFileName, bool useCompression, int compressionLevel);
181 
182 private:
184  GetImageIOBase(const PathType & fileName);
185 
186  template <class T>
187  Self &
188  ExecuteInternal(const Image &);
189 
192  std::string m_Compressor;
193 
196  std::string m_ImageIOName;
197 
198  // function pointer type
199  typedef Self & (Self::*MemberFunctionType)(const Image &);
200 
201  // friend to get access to executeInternal member
202  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
203 
204  std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType>> m_MemberFactory;
205 };
206 
219 SITKIO_EXPORT void
220 WriteImage(const Image & image, const PathType & fileName, bool useCompression = false, int compressionLevel = -1);
221 } // namespace simple
222 } // namespace itk
223 
224 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::ImageFileWriter::PixelIDTypeList
NonLabelPixelIDTypeList PixelIDTypeList
Definition: sitkImageFileWriter.h:57
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:29
itk::simple::ImageFileWriter::m_MemberFactory
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImageFileWriter.h:204
itk::simple::ImageFileWriter::m_UseCompression
bool m_UseCompression
Definition: sitkImageFileWriter.h:190
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
sitkImage.h
itk::simple::ImageFileWriter::m_Compressor
std::string m_Compressor
Definition: sitkImageFileWriter.h:192
itk::SmartPointer
Definition: sitkImage.h:38
sitkPathType.h
itk::simple::ImageFileWriter::UseCompressionOff
Self & UseCompressionOff()
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:97
itk::simple::ioutils::GetRegisteredImageIOs
SITKIO_HIDDEN std::vector< std::string > GetRegisteredImageIOs()
sitkMemberFunctionFactory.h
itk::simple::ImageFileWriter::m_KeepOriginalImageUID
bool m_KeepOriginalImageUID
Definition: sitkImageFileWriter.h:195
sitkProcessObject.h
sitkMacro.h
itk::simple::WriteImage
SITKIO_EXPORT void WriteImage(const Image &image, const PathType &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...
itk::simple::ImageFileWriter::KeepOriginalImageUIDOff
Self & KeepOriginalImageUIDOff()
Set/Get name of ImageIO to use.
Definition: sitkImageFileWriter.h:166
itk::simple::ImageFileWriter::UseCompressionOn
Self & UseCompressionOn()
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:92
itk::simple::NonLabelPixelIDTypeList
typelist2::append< BasicPixelIDTypeList, ComplexPixelIDTypeList, VectorPixelIDTypeList >::type NonLabelPixelIDTypeList
Definition: sitkPixelIDTypeLists.h:180
itk::simple::ImageFileWriter::m_FileName
PathType m_FileName
Definition: sitkImageFileWriter.h:194
itk::simple::ImageFileWriter::GetName
std::string GetName() const override
Definition: sitkImageFileWriter.h:69
itk
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:54
itk::simple::ImageFileWriter::KeepOriginalImageUIDOn
Self & KeepOriginalImageUIDOn()
Set/Get name of ImageIO to use.
Definition: sitkImageFileWriter.h:161
itk::simple::ImageFileWriter::m_CompressionLevel
int m_CompressionLevel
Definition: sitkImageFileWriter.h:191
itk::simple::ImageFileWriter::MemberFunctionType
Self &(Self::* MemberFunctionType)(const Image &)
Definition: sitkImageFileWriter.h:199
AddImageFilter
sitkIO.h
itk::simple::PathType
std::string PathType
Definition: sitkPathType.h:25
itk::simple::ImageFileWriter::m_ImageIOName
std::string m_ImageIOName
Definition: sitkImageFileWriter.h:196
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:51