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 "sitkImage.h"
24 #include "sitkIO.h"
25 #include "sitkProcessObject.h"
26 
27 #include <memory>
28 
29 namespace itk {
30 
31 // Forward declaration for pointer
32 class ImageIOBase;
33 
34 template<class T>
35 class SmartPointer;
36 
37  namespace simple {
38 
49  public ProcessObject
50  {
51  public:
53 
54  // list of pixel types supported
56 
57  ~ImageFileWriter() override;
58 
60 
62  std::string ToString() const override;
63 
65  std::string GetName() const override { return std::string("ImageFileWriter"); }
66 
69  virtual std::vector<std::string> GetRegisteredImageIOs() const;
70 
71 
78  SITK_RETURN_SELF_TYPE_HEADER SetUseCompression( bool UseCompression );
79  bool GetUseCompression( ) const;
80 
81  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOn( ) { return this->SetUseCompression(true); }
82  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOff( ) { return this->SetUseCompression(false); }
92  SITK_RETURN_SELF_TYPE_HEADER SetCompressionLevel(int);
93  int GetCompressionLevel() const;
102  SITK_RETURN_SELF_TYPE_HEADER SetCompressor(const std::string &);
103  std::string GetCompressor();
118  virtual SITK_RETURN_SELF_TYPE_HEADER SetImageIO(const std::string &imageio);
119  virtual std::string GetImageIO( ) const;
120  /* @} */
121 
122 
131  SITK_RETURN_SELF_TYPE_HEADER SetKeepOriginalImageUID( bool KeepOriginalImageUID );
132  bool GetKeepOriginalImageUID( ) const;
133 
134  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOn( ) { return this->SetKeepOriginalImageUID(true); }
135  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOff( ) { return this->SetKeepOriginalImageUID(false); }
138  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fileName );
139  std::string GetFileName() const;
140 
141  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& );
142  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& , const std::string &inFileName, bool useCompression, int compressionLevel );
143 
144  private:
145 
146  itk::SmartPointer<ImageIOBase> GetImageIOBase(const std::string &fileName);
147 
148  template <class T> Self& ExecuteInternal ( const Image& );
149 
152  std::string m_Compressor;
153 
154  std::string m_FileName;
156  std::string m_ImageIOName;
157 
158  // function pointer type
159  typedef Self& (Self::*MemberFunctionType)( const Image& );
160 
161  // friend to get access to executeInternal member
162  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
163 
164  std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
165 
166  };
167 
180  SITKIO_EXPORT void WriteImage (const Image& image,
181  const std::string &fileName,
182  bool useCompression=false,
183  int compressionLevel=-1);
184  }
185 }
186 
187 #endif
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::ImageFileWriter::PixelIDTypeList
NonLabelPixelIDTypeList PixelIDTypeList
Definition: sitkImageFileWriter.h:55
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:28
itk::simple::ImageFileWriter::m_MemberFactory
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImageFileWriter.h:164
itk::simple::ImageFileWriter::m_UseCompression
bool m_UseCompression
Definition: sitkImageFileWriter.h:150
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
sitkImage.h
itk::simple::ImageFileWriter::m_Compressor
std::string m_Compressor
Definition: sitkImageFileWriter.h:152
itk::SmartPointer
Definition: sitkImage.h:38
itk::simple::ImageFileWriter::UseCompressionOff
Self & UseCompressionOff()
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:82
itk::simple::ioutils::GetRegisteredImageIOs
SITKIO_HIDDEN std::vector< std::string > GetRegisteredImageIOs()
sitkMemberFunctionFactory.h
itk::simple::ImageFileWriter::m_KeepOriginalImageUID
bool m_KeepOriginalImageUID
Definition: sitkImageFileWriter.h:155
sitkProcessObject.h
sitkMacro.h
itk::simple::ImageFileWriter::KeepOriginalImageUIDOff
Self & KeepOriginalImageUIDOff()
Set/Get name of ImageIO to use.
Definition: sitkImageFileWriter.h:135
itk::simple::ImageFileWriter::UseCompressionOn
Self & UseCompressionOn()
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:81
itk::simple::NonLabelPixelIDTypeList
typelist2::append< BasicPixelIDTypeList, ComplexPixelIDTypeList, VectorPixelIDTypeList >::type NonLabelPixelIDTypeList
Definition: sitkPixelIDTypeLists.h:180
itk::simple::WriteImage
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &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::GetName
std::string GetName() const override
Definition: sitkImageFileWriter.h:65
itk::simple::ImageFileWriter::m_FileName
std::string m_FileName
Definition: sitkImageFileWriter.h:154
itk
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:51
itk::simple::ImageFileWriter::KeepOriginalImageUIDOn
Self & KeepOriginalImageUIDOn()
Set/Get name of ImageIO to use.
Definition: sitkImageFileWriter.h:134
itk::simple::ImageFileWriter::m_CompressionLevel
int m_CompressionLevel
Definition: sitkImageFileWriter.h:151
itk::simple::ImageFileWriter::MemberFunctionType
Self &(Self::* MemberFunctionType)(const Image &)
Definition: sitkImageFileWriter.h:159
AddImageFilter
sitkIO.h
itk::simple::ImageFileWriter::m_ImageIOName
std::string m_ImageIOName
Definition: sitkImageFileWriter.h:156
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:48