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 
15 #ifndef __itkImageFileCastWriter_h
16 #define __itkImageFileCastWriter_h
17 
18 #include "itkImageFileWriter.h"
19 #include "itkImageIOBase.h"
20 #include "itkExceptionObject.h"
21 #include "itkSize.h"
22 #include "itkImageIORegion.h"
23 #include "itkCastImageFilter.h"
24 
25 
26 namespace itk
27 {
28 
37 template <class TInputImage >
38  class ImageFileCastWriter : public ImageFileWriter<TInputImage>
39 {
40 public:
44  typedef SmartPointer<Self> Pointer;
45  typedef SmartPointer<const Self> ConstPointer;
46 
48  itkNewMacro(Self);
49 
52 
54  typedef typename Superclass::InputImageType InputImageType;
55  typedef typename Superclass::InputImagePointer InputImagePointer;
56  typedef typename Superclass::InputImageRegionType InputImageRegionType;
57  typedef typename Superclass::InputImagePixelType InputImagePixelType;
58 
59  itkStaticConstMacro( InputImageDimension, unsigned int, InputImageType::ImageDimension );
60 
64  itkSetStringMacro(OutputComponentType);
65  itkGetStringMacro(OutputComponentType);
66 
68  std::string GetDefaultOutputComponentType(void) const;
69 
70 protected:
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 
94  typename CasterType::Pointer caster = CasterType::New();
95  this->m_Caster = caster;
96  typename ScalarInputImageType::Pointer localInputImage = ScalarInputImageType::New();
97  localInputImage->Graft( inputImage );
98  caster->SetInput( localInputImage );
99  caster->Update();
100 
102  OutputComponentType * pixelBuffer = caster->GetOutput()->GetBufferPointer();
103  void * convertedBuffer = static_cast<void *>(pixelBuffer);
104  return convertedBuffer;
105  }
106 
107  ProcessObject::Pointer m_Caster;
108 
109 private:
110  ImageFileCastWriter(const Self&); //purposely not implemented
111  void operator=(const Self&); //purposely not implemented
112 
114 };
115 
116 
117 } // end namespace itk
118 
119 #ifndef ITK_MANUAL_INSTANTIATION
120 #include "itkImageFileCastWriter.txx"
121 #endif
122 
123 #endif // __itkImageFileCastWriter_h
124 
Superclass::InputImageType InputImageType
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
Casts pixel type and writes image data.
Superclass::InputImagePixelType InputImagePixelType
ImageFileWriter< TInputImage > Superclass
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)


Generated on 05-12-2013 for elastix by doxygen 1.8.5 elastix logo