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  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 #ifndef __itkImageFileCastWriter_h
15 #define __itkImageFileCastWriter_h
16 
17 #include "itkImageFileWriter.h"
18 #include "itkImageIOBase.h"
19 #include "itkExceptionObject.h"
20 #include "itkSize.h"
21 #include "itkImageIORegion.h"
22 #include "itkCastImageFilter.h"
23 
24 namespace itk
25 {
26 
35 template< class TInputImage >
36 class ImageFileCastWriter : public ImageFileWriter< TInputImage >
37 {
38 public:
39 
43  typedef SmartPointer< Self > Pointer;
44  typedef SmartPointer< const Self > ConstPointer;
45 
47  itkNewMacro( Self );
48 
51 
53  typedef typename Superclass::InputImageType InputImageType;
54  typedef typename Superclass::InputImagePointer InputImagePointer;
55  typedef typename Superclass::InputImageRegionType InputImageRegionType;
56  typedef typename Superclass::InputImagePixelType InputImagePixelType;
57 
58  itkStaticConstMacro( InputImageDimension, unsigned int, InputImageType::ImageDimension );
59 
63  itkSetStringMacro( OutputComponentType );
64  itkGetStringMacro( OutputComponentType );
65 
67  std::string GetDefaultOutputComponentType( void ) const;
68 
69 protected:
70 
73 
75  void GenerateData( void );
76 
81  template< class OutputComponentType >
82  void * ConvertScalarImage( const DataObject * inputImage,
83  const OutputComponentType & itkNotUsed( dummy ) )
84  {
85  typedef Image< OutputComponentType, InputImageDimension > DiskImageType;
86  typedef typename PixelTraits< InputImagePixelType >::ValueType InputImageComponentType;
87  typedef Image< InputImageComponentType, InputImageDimension > ScalarInputImageType;
88  typedef CastImageFilter< ScalarInputImageType, DiskImageType > CasterType;
89 
91  //this->GetImageIO()->SetPixelTypeInfo( typeid(OutputComponentType) );
92  this->GetImageIO()->SetPixelTypeInfo( static_cast< const OutputComponentType * >( 0 ) );
93 
95  typename CasterType::Pointer caster = CasterType::New();
96  this->m_Caster = caster;
97  typename ScalarInputImageType::Pointer localInputImage = ScalarInputImageType::New();
98  localInputImage->Graft( inputImage );
99  caster->SetInput( localInputImage );
100  caster->Update();
101 
103  OutputComponentType * pixelBuffer = caster->GetOutput()->GetBufferPointer();
104  void * convertedBuffer = static_cast< void * >( pixelBuffer );
105  return convertedBuffer;
106  }
107 
108 
109  ProcessObject::Pointer m_Caster;
110 
111 private:
112 
113  ImageFileCastWriter( const Self & ); // purposely not implemented
114  void operator=( const Self & ); // purposely not implemented
115 
117 };
118 
119 } // end namespace itk
120 
121 #ifndef ITK_MANUAL_INSTANTIATION
122 #include "itkImageFileCastWriter.hxx"
123 #endif
124 
125 #endif // __itkImageFileCastWriter_h
Superclass::InputImageType InputImageType
Casts pixel type and writes image data.
SmartPointer< const Self > ConstPointer
Superclass::InputImagePixelType InputImagePixelType
SmartPointer< Self > Pointer
void operator=(const Self &)
void * ConvertScalarImage(const DataObject *inputImage, const OutputComponentType &)
Superclass::InputImageRegionType InputImageRegionType
Superclass::InputImagePointer InputImagePointer
ProcessObject::Pointer m_Caster
std::string GetDefaultOutputComponentType(void) const
itkStaticConstMacro(InputImageDimension, unsigned int, InputImageType::ImageDimension)
ImageFileWriter< TInputImage > Superclass


Generated on 11-03-2014 for elastix by doxygen 1.8.6 elastix logo