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
30namespace itk
31{
32
33// Forward declaration for pointer
34class ImageIOBase;
35
36template <class T>
37class SmartPointer;
38
39namespace simple
40{
41
52{
53public:
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>
78
79
86 SITK_RETURN_SELF_TYPE_HEADER
87 SetUseCompression(bool UseCompression);
88 bool
90
91 SITK_RETURN_SELF_TYPE_HEADER
92 UseCompressionOn() { return this->SetUseCompression(true); }
93 SITK_RETURN_SELF_TYPE_HEADER
94 UseCompressionOff() { return this->SetUseCompression(false); }
96
97
104 SITK_RETURN_SELF_TYPE_HEADER
106 int
109
116 SITK_RETURN_SELF_TYPE_HEADER
117 SetCompressor(const std::string &);
118 std::string
121
134 virtual SITK_RETURN_SELF_TYPE_HEADER
135 SetImageIO(const std::string & imageio);
136 virtual std::string
137 GetImageIO() const;
138 /* @} */
139
140
149 SITK_RETURN_SELF_TYPE_HEADER
150 SetKeepOriginalImageUID(bool KeepOriginalImageUID);
151 bool
153
154 SITK_RETURN_SELF_TYPE_HEADER
156 SITK_RETURN_SELF_TYPE_HEADER
159
160 SITK_RETURN_SELF_TYPE_HEADER
161 SetFileName(const PathType & fileName);
163 GetFileName() const;
164
165 SITK_RETURN_SELF_TYPE_HEADER
166 Execute(const Image &);
167 SITK_RETURN_SELF_TYPE_HEADER
168 Execute(const Image &, const PathType & inFileName, bool useCompression, int compressionLevel);
169
170private:
172 GetImageIOBase(const PathType & fileName);
173
174 template <class T>
175 Self &
177
180 std::string m_Compressor;
181
184 std::string m_ImageIOName;
185
186 // function pointer type
187 typedef Self & (Self::*MemberFunctionType)(const Image &);
188
189 // friend to get access to executeInternal member
191
192 std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType>> m_MemberFactory;
193};
194
207SITKIO_EXPORT void
208WriteImage(const Image & image, const PathType & fileName, bool useCompression = false, int compressionLevel = -1);
209} // namespace simple
210} // namespace itk
211
212#endif
Self & UseCompressionOff()
Enable compression if available for file type.
itk::SmartPointer< ImageIOBase > GetImageIOBase(const PathType &fileName)
bool GetUseCompression() const
Enable compression if available for file type.
virtual Self & SetImageIO(const std::string &imageio)
Set/Get name of ImageIO to use.
virtual std::vector< std::string > GetRegisteredImageIOs() const
Get a vector of the names of registered itk ImageIOs.
std::string ToString() const override
Self & ExecuteInternal(const Image &)
virtual std::string GetImageIO() const
Set/Get name of ImageIO to use.
Self & KeepOriginalImageUIDOn()
Set/Get name of ImageIO to use.
Self & SetFileName(const PathType &fileName)
Self & KeepOriginalImageUIDOff()
Set/Get name of ImageIO to use.
Self &(Self::* MemberFunctionType)(const Image &)
Self & SetUseCompression(bool UseCompression)
Enable compression if available for file type.
Self & SetCompressionLevel(int)
A hint for the amount of compression to be applied during writing.
std::string GetName() const override
PathType GetFileName() const
bool GetKeepOriginalImageUID() const
Set/Get name of ImageIO to use.
Self & Execute(const Image &, const PathType &inFileName, bool useCompression, int compressionLevel)
std::string GetCompressor()
A compression algorithm hint.
NonLabelPixelIDTypeList PixelIDTypeList
Self & SetCompressor(const std::string &)
A compression algorithm hint.
Self & UseCompressionOn()
Enable compression if available for file type.
int GetCompressionLevel() const
A hint for the amount of compression to be applied during writing.
Self & SetKeepOriginalImageUID(bool KeepOriginalImageUID)
Use the original study/series/frame of reference.
Self & Execute(const Image &)
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
The Image class for SimpleITK.
Definition sitkImage.h:77
std::string PathType
typelist2::append< BasicPixelIDTypeList, ComplexPixelIDTypeList, VectorPixelIDTypeList >::type NonLabelPixelIDTypeList
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...
#define SITKIO_EXPORT
Definition sitkIO.h:33