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 "itkExceptionObject.h"
24 #include "itkSize.h"
25 #include "itkImageIORegion.h"
26 #include "itkCastImageFilter.h"
27 
28 namespace itk
29 {
30 
39 template< class TInputImage >
40 class ImageFileCastWriter : public ImageFileWriter< TInputImage >
41 {
42 public:
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 
73 protected:
74 
77 
79  void GenerateData( void );
80 
85  template< class OutputComponentType >
86  void * ConvertScalarImage( const DataObject * inputImage,
87  const OutputComponentType & itkNotUsed( dummy ) )
88  {
90  typedef typename PixelTraits< InputImagePixelType >::ValueType InputImageComponentType;
91  typedef Image< InputImageComponentType, InputImageDimension > ScalarInputImageType;
92  typedef CastImageFilter< ScalarInputImageType, DiskImageType > CasterType;
93 
95  //this->GetImageIO()->SetPixelTypeInfo( typeid(OutputComponentType) );
96  this->GetImageIO()->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  localInputImage->Graft( inputImage );
103  caster->SetInput( localInputImage );
104  caster->Update();
105 
107  OutputComponentType * pixelBuffer = caster->GetOutput()->GetBufferPointer();
108  void * convertedBuffer = static_cast< void * >( pixelBuffer );
109  return convertedBuffer;
110  }
111 
112 
113  ProcessObject::Pointer m_Caster;
114 
115 private:
116 
117  ImageFileCastWriter( const Self & ); // purposely not implemented
118  void operator=( const Self & ); // purposely not implemented
119 
121 };
122 
123 } // end namespace itk
124 
125 #ifndef ITK_MANUAL_INSTANTIATION
126 #include "itkImageFileCastWriter.hxx"
127 #endif
128 
129 #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 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo