18#ifndef itkImageFileWriter_h
19#define itkImageFileWriter_h
20#include "ITKIOImageBaseExport.h"
45 const char * message =
"Error in IO",
46 const char * loc =
"Unknown")
53 const char * message =
"Error in IO",
54 const char * loc =
"Unknown")
89template <typename TInputImage>
125 itkSetStringMacro(FileName);
126 itkGetStringMacro(FileName);
175 itkSetMacro(NumberOfStreamDivisions,
unsigned int);
176 itkGetConstReferenceMacro(NumberOfStreamDivisions,
unsigned int);
201 itkSetMacro(UseCompression,
bool);
202 itkGetConstReferenceMacro(UseCompression,
bool);
203 itkBooleanMacro(UseCompression);
208 itkSetMacro(CompressionLevel,
int);
209 itkGetConstReferenceMacro(CompressionLevel,
int);
218 itkSetMacro(UseInputMetaDataDictionary,
bool);
219 itkGetConstReferenceMacro(UseInputMetaDataDictionary,
bool);
220 itkBooleanMacro(UseInputMetaDataDictionary);
254template <
typename TImagePo
inter>
255ITK_TEMPLATE_EXPORT
void
256WriteImage(TImagePointer && image,
const std::string & filename,
bool compress =
false)
258 using NonReferenceImagePointer = std::remove_reference_t<TImagePointer>;
259 static_assert(std::is_pointer_v<NonReferenceImagePointer> || mpl::IsSmartPointer<NonReferenceImagePointer>::Value,
260 "WriteImage requires a raw pointer or SmartPointer.");
263 using ImageType = std::remove_const_t<std::remove_reference_t<
decltype(*image)>>;
265 writer->SetInput(image);
266 writer->SetFileName(filename);
267 writer->SetUseCompression(compress);
273#ifndef ITK_MANUAL_INSTANTIATION
274# include "itkImageFileWriter.hxx"
277#if defined ITK_IMAGEIO_FACTORY_REGISTER_MANAGER || defined ITK_IO_FACTORY_REGISTER_MANAGER
278# include "itkImageIOFactoryRegisterManager.h"
ExceptionObject() noexcept=default
~ImageFileWriterException() noexcept override
ImageFileWriterException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
ImageFileWriterException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
ITK_DEFAULT_COPY_AND_MOVE(ImageFileWriterException)
bool m_UseInputMetaDataDictionary
void PrintSelf(std::ostream &os, Indent indent) const override
void SetIORegion(const ImageIORegion ®ion)
~ImageFileWriter() override=default
void SetInput(const InputImageType *input)
void SetImageIO(ImageIOBase *io)
SmartPointer< const Self > ConstPointer
void GenerateData() override
ImageIOBase::Pointer m_ImageIO
typename InputImageType::PixelType InputImagePixelType
TInputImage InputImageType
const InputImageType * GetInput(unsigned int idx)
ImageFileWriter()=default
const ImageIORegion & GetIORegion() const
bool m_UserSpecifiedImageIO
ImageIORegion m_PasteIORegion
bool m_FactorySpecifiedImageIO
bool m_UserSpecifiedIORegion
const InputImageType * GetInput()
unsigned int m_NumberOfStreamDivisions
SmartPointer< Self > Pointer
typename InputImageType::Pointer InputImagePointer
typename InputImageType::RegionType InputImageRegionType
void UpdateLargestPossibleRegion() override
Writes the entire image to file.
Abstract superclass defines image IO interface.
SmartPointer< Self > Pointer
An ImageIORegion represents a structured region of data.
Control indentation during Print() invocation.
virtual void Modified() const
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITK_TEMPLATE_EXPORT void WriteImage(TImagePointer &&image, const std::string &filename, bool compress=false)