Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPyramidImageRegistrationMethod.h
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 MITKPYRAMIDIMAGEREGISTRATION_H
18 #define MITKPYRAMIDIMAGEREGISTRATION_H
19 
21 
22 #include <itkObject.h>
23 #include "itkImageMaskSpatialObject.h"
24 #include "itkNotImageFilter.h"
25 #include <itkCenteredVersorTransformInitializer.h>
26 #include <vnl/vnl_matrix_fixed.h>
27 
28 #include "mitkImage.h"
29 #include "mitkBaseProcess.h"
30 
32 #include <itkWindowedSincInterpolateImageFunction.h>
33 
34 #include "mitkImageToItk.h"
35 #include "mitkImageCast.h"
36 #include "mitkImageCaster.h"
37 #include "mitkITKImageImport.h"
38 #include "mitkIOUtil.h"
39 
40 
41 namespace mitk
42 {
43 
59  public itk::Object
60 {
61 public:
62 
65 
66 
67  itkFactorylessNewMacro(Self)
68  itkCloneMacro(Self)
69 
71 
73  typedef vnl_matrix_fixed< double, 3, 3> TransformMatrixType;
74 
75  typedef itk::AffineTransform< double > AffineTransformType;
76  typedef itk::Euler3DTransform< double > RigidTransformType;
77 
79  void SetCrossModalityOn()
80  {
81  m_CrossModalityRegistration = true;
82  }
83 
86  {
87  m_CrossModalityRegistration = false;
88  }
89 
91  void SetCrossModality(bool flag)
92  {
93  if( flag )
94  this->SetCrossModalityOn();
95  else
96  this->SetCrossModalityOff();
97  }
98 
103  void SetVerbose(bool flag)
104  {
105  if( flag )
106  this->SetVerboseOn();
107  else
108  this->SetVerboseOff();
109  }
110 
113  {
114  m_Verbose = true;
115  }
116 
119  {
120  m_Verbose = false;
121  }
122 
125  {
126  m_UseAffineTransform = false;
127  }
128 
131  {
132  m_UseAffineTransform = true;
133  }
134 
136  void SetFixedImage( mitk::Image::Pointer );
137 
139  void SetMovingImage( mitk::Image::Pointer );
140 
142  void SetFixedImageMask( mitk::Image::Pointer mask);
143 
148  void SetInitializeByGeometry(bool flag)
149  {
150  m_InitializeByGeometry = flag;
151  }
152 
153  void Update();
154 
160  unsigned int GetNumberOfParameters()
161  {
162  unsigned int retValue = 12;
163  if(!m_UseAffineTransform)
164  retValue = 6;
165 
166  return retValue;
167  }
168 
173  void GetParameters( double* paramArray)
174  {
175  if( m_EstimatedParameters == NULL )
176  {
177  mitkThrow() << "No parameters were estimated yet, call Update() first.";
178  }
179 
180  unsigned int dim = 12;
181  if( !m_UseAffineTransform )
182  dim = 6;
183 
184  for( unsigned int i=0; i<dim; i++)
185  {
186  *(paramArray+i) = m_EstimatedParameters[i];
187  }
188  }
189 
196  {
197  if( m_EstimatedParameters == NULL )
198  {
199  mitkThrow() << "No parameters were estimated yet, call Update() first.";
200  }
201 
202  unsigned int dim = 12;
203  if( !m_UseAffineTransform )
204  dim = 6;
205 
206  ParametersType params(dim);
207 
208  params.SetData( m_EstimatedParameters );
209  return params;
210  }
211 
219  {
220  m_InitialParameters = params;
221  }
222 
234  {
235  m_UseWindowedSincInterpolator = flag;
236  }
237 
248  {
249  m_UseNearestNeighborInterpolator = flag;
250  }
251 
256  void SetUseFixedImageMask( bool flag)
257  {
258  m_UseMask = flag;
259  }
260 
266  mitk::Image::Pointer GetResampledMovingImage();
267 
272  mitk::Image::Pointer GetResampledMovingImage(mitk::Image::Pointer movingImage, double *transform );
273 
281  TransformMatrixType GetLastRotationMatrix();
282 
283 
284 protected:
286 
288 
291 
294 
296 
298 
300 
302 
304 
305  bool m_UseMask;
306 
308 
310 
312  bool m_Verbose;
313 
315 
324 template <typename TPixel1, unsigned int VImageDimension1, typename TPixel2, unsigned int VImageDimension2>
325  void RegisterTwoImagesV4(itk::Image<TPixel1, VImageDimension1>* itkImage1, itk::Image<TPixel2, VImageDimension2>* itkImage2);
326 
333  template< typename TPixel, unsigned int VDimension>
334  void ResampleMitkImage( itk::Image<TPixel, VDimension>* itkImage,
335  mitk::Image::Pointer& outputImage );
336 
337 };
338 
339 } // end namespace
340 
341 #endif // MITKPYRAMIDIMAGEREGISTRATION_H
void GetParameters(double *paramArray)
Copies the estimated parameters to the given array.
ParametersType GetLastRegistrationParameters()
Retrieve the parameters of the last registration computed.
itk::OptimizerParameters< double > ParametersType
void SetUseFixedImageMask(bool flag)
Set if fixed image mask is used to exclude a region.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
DataCollection - Class to facilitate loading/accessing structured data.
The PyramidImageRegistration class implements a multi-scale registration method.
#define MITKDIFFUSIONCORE_EXPORT
This class is used to hold all optimizer parameters needed for a rigid registration process...
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
#define mitkThrow()
void SetUseNearestNeighborInterpolation(bool flag)
Control the interpolator used for resampling.
vnl_matrix_fixed< double, 3, 3 > TransformMatrixType
void SetInitialParameters(ParametersType &params)
Set the starting position of the registration.
unsigned int GetNumberOfParameters()
Get the number of parameters optimized ( 12 or 6 )
void SetInitializeByGeometry(bool flag)
Use the itk::CenteredVersorTransformInitializer to perform initialization step for the registration...
void SetUseAdvancedInterpolation(bool flag)
Control the interpolator used for resampling.