Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkVectorImageToImageFilter.txx
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __itkVectorImageToImageFilter_txx
18 #define __itkVectorImageToImageFilter_txx
19 
20 #include <time.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #define _USE_MATH_DEFINES
25 #include <math.h>
26 
27 #include "itkImageRegionIterator.h"
28 
29 
30 namespace itk {
31 
32 
33 template< class TPixelType >
34 VectorImageToImageFilter< TPixelType >
35 ::VectorImageToImageFilter()
36  : m_Index(0)
37 {
38  this->SetNumberOfRequiredInputs( 1 );
39 }
40 
41 template< class TPixelType >
42 void
43 VectorImageToImageFilter< TPixelType >
44 ::GenerateData()
45 {
46  typename OutputImageType::Pointer outputImage =
47  static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
48 
49  outputImage->SetSpacing(this->GetInput()->GetSpacing());
50  outputImage->SetOrigin(this->GetInput()->GetOrigin());
51  outputImage->SetRegions(this->GetInput()->GetLargestPossibleRegion());
52  outputImage->Allocate();
53 
54  ImageRegionIterator< OutputImageType > oit(outputImage, outputImage->GetLargestPossibleRegion());
55  oit.GoToBegin();
56 
57  // InputIteratorType;
58  typename InputImageType::Pointer inputImagePointer = NULL;
59  inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
60 
61  ImageRegionIterator <InputImageType> git( inputImagePointer, inputImagePointer->GetLargestPossibleRegion() );
62  git.GoToBegin();
63  while( !git.IsAtEnd() )
64  {
65  oit.Set(git.Get()[m_Index]);
66  ++oit;
67  ++git;
68  }
69 }
70 
71 template< class TPixelType >
72 void VectorImageToImageFilter< TPixelType >::PrintSelf(std::ostream& os, Indent indent) const
73 {
74  Superclass::PrintSelf(os,indent);
75 }
76 
77 }
78 
79 #endif // __itkVectorImageToImageFilter_txx