Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkITKImageToImageFilterF2F2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: vtkITK
9  Module: $HeadURL$
10  Date: $Date$
11  Version: $Revision$
12 
13 ==========================================================================*/
14 
15 #ifndef __vtkITKImageToImageFilterF2F2_h
16 #define __vtkITKImageToImageFilterF2F2_h
17 
19 #include "vtkImageAlgorithm.h"
20 #include "vtkImageAppendComponents.h"
21 #include "itkImageToImageFilter.h"
22 #include "itkSplitImageFilter.h"
23 #include "itkJoinImageFilter.h"
24 #include "itkVTKImageExport.h"
25 #include "itkVTKImageImport.h"
26 #include "vtkITKUtility.h"
27 #include <vtkVersion.h>
28 
30 {
31 public:
33  static vtkITKImageToImageFilterF2F2* New() { return 0; };
34  void PrintSelf(ostream& os, vtkIndent indent)
35  {
36  Superclass::PrintSelf ( os, indent );
37  os << m_Filter;
38  };
39 
42  virtual void SetInput1(vtkImageData *Input)
43  {
44  this->SetInput ( Input );
45  };
46  virtual void SetInput2(vtkImageData *Input)
47  {
48  this->vtkImageAlgorithm::SetInput(1, Input);
49  this->vtkExporter1->SetInputData(Input);
50  };
51 
52  virtual vtkImageData *GetOutput() { return this->append->GetOutput(); };
53 
54 protected:
55 
57  typedef itk::Vector<float,2> InputImagePixelType;
58  typedef itk::Vector<float,2> OutputImagePixelType;
59  typedef itk::Image<InputImagePixelType, 3> InputImageType;
60  typedef itk::Image<OutputImagePixelType, 3> OutputImageType;
61 
62  typedef itk::Image<float, 3> JoinImageType;
63  typedef itk::VTKImageImport<JoinImageType> ImageImportType;
64  typedef itk::VTKImageExport<JoinImageType> ImageExportType;
65  ImageImportType::Pointer itkImporter;
66  ImageExportType::Pointer itkExporter;
67  ImageImportType::Pointer itkImporter1;
68  ImageExportType::Pointer itkExporter1;
69 
70  typedef itk::JoinImageFilter<JoinImageType, JoinImageType> JoinFilterType;
71 
72  typedef itk::SplitImageFilter<OutputImageType, JoinImageType> SplitFilterType;
73 
74  typedef itk::ImageToImageFilter<InputImageType,OutputImageType> GenericFilterType;
75  GenericFilterType::Pointer m_Filter;
76 
77  vtkImageImport* vtkImporter1;
78  vtkImageExport* vtkExporter1;
79  vtkImageAppendComponents* append;
80  SplitFilterType::Pointer split1, split;
81  JoinFilterType::Pointer join;
82 
84  {
85  this->vtkImporter1 = vtkImageImport::New();
86  this->vtkExporter1 = vtkImageExport::New();
88  m_Filter = filter;
89  this->itkImporter = ImageImportType::New();
90  this->itkExporter = ImageExportType::New();
91  ConnectPipelines(this->vtkExporter, this->itkImporter);
92  ConnectPipelines(this->itkExporter, this->vtkImporter);
93 
94  this->itkImporter1 = ImageImportType::New();
95  this->itkExporter1 = ImageExportType::New();
96  ConnectPipelines(this->vtkExporter1, this->itkImporter1);
97  ConnectPipelines(this->itkExporter1, this->vtkImporter1);
98  this->LinkITKProgressToVTKProgress ( m_Filter );
99 
102  join = JoinFilterType::New();
103  join->SetInput1 ( this->itkImporter->GetOutput() );
104  join->SetInput2 ( this->itkImporter->GetOutput() );
105 
106  m_Filter->SetInput ( join->GetOutput() );
108 
109  split = SplitFilterType::New();
111  split->SetInput ( m_Filter->GetOutput() );
112  split->SetIndex ( 0 );
113  split1 = SplitFilterType::New();
115  split1->SetInput ( m_Filter->GetOutput() );
116  split1->SetIndex ( 1 );
117 
118  this->itkExporter->SetInput ( split->GetOutput() );
119  this->itkExporter1->SetInput ( split1->GetOutput() );
120 
121  this->append = vtkImageAppendComponents::New();
122  this->append->SetInput ( 0, this->vtkImporter->GetOutput() );
123  this->append->SetInput ( 1, this->vtkImporter1->GetOutput() );
124  this->vtkCast->SetOutputScalarTypeToFloat();
125 
139  };
140 
142  {
143  this->vtkExporter1->Delete();
144  this->vtkImporter1->Delete();
145  this->append->Delete();
146  };
147 
148 private:
150  void operator=(const vtkITKImageToImageFilterF2F2&);
151 };
152 
153 #endif
154 
155 
156 
157 
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer *importer)
Definition: vtkITKUtility.h:26
virtual vtkImageData * GetOutput()
itk::VTKImageExport< JoinImageType > ImageExportType
static vtkITKImageToImageFilterF2F2 * New()
itk::Image< InputImagePixelType, 3 > InputImageType
itk::VTKImageImport< JoinImageType > ImageImportType
itk::Image< OutputImagePixelType, 3 > OutputImageType
itk::SplitImageFilter< OutputImageType, JoinImageType > SplitFilterType
Abstract base class for connecting ITK and VTK.
vtkITKImageToImageFilterF2F2(GenericFilterType *filter)
itk::JoinImageFilter< JoinImageType, JoinImageType > JoinFilterType
itk::Vector< float, 2 > OutputImagePixelType
void PrintSelf(ostream &os, vtkIndent indent)
virtual void SetInput2(vtkImageData *Input)
itk::ImageToImageFilter< InputImageType, OutputImageType > GenericFilterType
virtual void SetInput(vtkImageData *Input)
Set the Input of the filter.
virtual void SetInput1(vtkImageData *Input)
Set the Input of the filter.
void LinkITKProgressToVTKProgress(itk::ProcessObject *process)
BTX.