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 void
87 SetUseCompression(bool UseCompression);
88 bool
90
91 void
93 {
94 return this->SetUseCompression(true);
95 }
96 void
98 {
99 return this->SetUseCompression(false);
100 }
101
102
103
110 void
112 int
115
122 void
123 SetCompressor(const std::string &);
124 std::string
127
140 virtual void
141 SetImageIO(const std::string & imageio);
142 virtual std::string
143 GetImageIO() const;
144 /* @} */
145
146
155 void
156 SetKeepOriginalImageUID(bool KeepOriginalImageUID);
157 bool
159
160 void
162 {
163 return this->SetKeepOriginalImageUID(true);
164 }
165 void
167 {
168 return this->SetKeepOriginalImageUID(false);
169 }
170
171
172 void
173 SetFileName(const PathType & fileName);
175 GetFileName() const;
176
177 void
178 Execute(const Image &);
179 void
180 Execute(const Image &, const PathType & inFileName, bool useCompression, int compressionLevel);
181
182private:
184 GetImageIOBase(const PathType & fileName);
185
186 template <class T>
187 void
189
190 bool m_UseCompression{ false };
192 std::string m_Compressor;
193
196 std::string m_ImageIOName;
197
198 // function pointer type
199 typedef void (Self::*MemberFunctionType)(const Image &);
200
201 // friend to get access to executeInternal member
203
206};
207
220SITKIO_EXPORT void
221WriteImage(const Image & image, const PathType & fileName, bool useCompression = false, int compressionLevel = -1);
222} // namespace simple
223} // namespace itk
224
225#endif
itk::SmartPointer< ImageIOBase > GetImageIOBase(const PathType &fileName)
bool GetUseCompression() const
Enable compression if available for file type.
void SetCompressionLevel(int)
A hint for the amount of compression to be applied during writing.
virtual std::vector< std::string > GetRegisteredImageIOs() const
Get a vector of the names of registered itk ImageIOs.
std::string ToString() const override
void UseCompressionOn()
Enable compression if available for file type.
void KeepOriginalImageUIDOn()
Set/Get name of ImageIO to use.
virtual std::string GetImageIO() const
Set/Get name of ImageIO to use.
void UseCompressionOff()
Enable compression if available for file type.
virtual void SetImageIO(const std::string &imageio)
Set/Get name of ImageIO to use.
void ExecuteInternal(const Image &)
std::string GetName() const override
PathType GetFileName() const
void Execute(const Image &)
void SetKeepOriginalImageUID(bool KeepOriginalImageUID)
Use the original study/series/frame of reference.
static const detail::MemberFunctionFactory< MemberFunctionType > & GetMemberFunctionFactory()
bool GetKeepOriginalImageUID() const
Set/Get name of ImageIO to use.
void SetCompressor(const std::string &)
A compression algorithm hint.
std::string GetCompressor()
A compression algorithm hint.
NonLabelPixelIDTypeList PixelIDTypeList
void SetFileName(const PathType &fileName)
void KeepOriginalImageUIDOff()
Set/Get name of ImageIO to use.
void(Self::* MemberFunctionType)(const Image &)
int GetCompressionLevel() const
A hint for the amount of compression to be applied during writing.
void SetUseCompression(bool UseCompression)
Enable compression if available for file type.
void Execute(const Image &, const PathType &inFileName, bool useCompression, int compressionLevel)
The Image class for SimpleITK.
Definition sitkImage.h:77
A class used to instantiate and generate function object to templated member functions.
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