go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkImageFileCastWriter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 __itkImageFileCastWriter_h
19#define __itkImageFileCastWriter_h
20
21#include "itkImageFileWriter.h"
22#include "itkImageIOBase.h"
23#include "itkMacro.h"
24#include "itkSize.h"
25#include "itkImageIORegion.h"
26#include "itkCastImageFilter.h"
27
28namespace itk
29{
30
39template< class TInputImage >
40class ITKIOImageBase_HIDDEN ImageFileCastWriter : public ImageFileWriter< TInputImage >
41{
42public:
43
48 typedef SmartPointer< const Self > ConstPointer;
49
51 itkNewMacro( Self );
52
55
57 typedef typename Superclass::InputImageType InputImageType;
58 typedef typename Superclass::InputImagePointer InputImagePointer;
59 typedef typename Superclass::InputImageRegionType InputImageRegionType;
60 typedef typename Superclass::InputImagePixelType InputImagePixelType;
61
62 itkStaticConstMacro( InputImageDimension, unsigned int, InputImageType::ImageDimension );
63
67 itkSetStringMacro( OutputComponentType );
68 itkGetStringMacro( OutputComponentType );
69
71 std::string GetDefaultOutputComponentType( void ) const;
72
73protected:
74
77
79 void GenerateData( void ) override;
80
85 template< class OutputComponentType >
86 void * ConvertScalarImage( const DataObject * inputImage,
87 const OutputComponentType & itkNotUsed( dummy ) )
88 {
90 typedef typename PixelTraits< InputImagePixelType >::ValueType InputImageComponentType;
92 typedef CastImageFilter< ScalarInputImageType, DiskImageType > CasterType;
93
95 //this->GetImageIO()->SetPixelTypeInfo( typeid(OutputComponentType) );
96 this->GetModifiableImageIO()->SetPixelTypeInfo( static_cast< const OutputComponentType * >( 0 ) );
97
99 typename CasterType::Pointer caster = CasterType::New();
100 this->m_Caster = caster;
101 typename ScalarInputImageType::Pointer localInputImage = ScalarInputImageType::New();
102
103 localInputImage->Graft( static_cast< const ScalarInputImageType * >(inputImage) );
104
105 caster->SetInput( localInputImage );
106 caster->Update();
107
109 OutputComponentType * pixelBuffer = caster->GetOutput()->GetBufferPointer();
110 void * convertedBuffer = static_cast< void * >( pixelBuffer );
111 return convertedBuffer;
112 }
113
114
115 ProcessObject::Pointer m_Caster;
116
117private:
118
119 ImageFileCastWriter( const Self & ); // purposely not implemented
120 void operator=( const Self & ); // purposely not implemented
121
123};
124
125} // end namespace itk
126
127#ifndef ITK_MANUAL_INSTANTIATION
128#include "itkImageFileCastWriter.hxx"
129#endif
130
131#endif // __itkImageFileCastWriter_h
Casts pixel type and writes image data.
itkStaticConstMacro(InputImageDimension, unsigned int, InputImageType::ImageDimension)
ImageFileCastWriter(const Self &)
SmartPointer< const Self > ConstPointer
void GenerateData(void) override
Superclass::InputImagePointer InputImagePointer
ProcessObject::Pointer m_Caster
Superclass::InputImageType InputImageType
void * ConvertScalarImage(const DataObject *inputImage, const OutputComponentType &)
SmartPointer< Self > Pointer
void operator=(const Self &)
Superclass::InputImageRegionType InputImageRegionType
~ImageFileCastWriter() override
ImageFileWriter< TInputImage > Superclass
Superclass::InputImagePixelType InputImagePixelType
std::string GetDefaultOutputComponentType(void) const


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo