Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkExtractSliceFilter.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkExtractSliceFilter_h_Included
14 #define mitkExtractSliceFilter_h_Included
15 
16 #include "MitkCoreExports.h"
17 #include "mitkImageToImageFilter.h"
18 
19 #include <vtkAbstractTransform.h>
20 #include <vtkImageData.h>
21 #include <vtkImageReslice.h>
22 #include <vtkMatrix4x4.h>
23 #include <vtkPoints.h>
24 #include <vtkSmartPointer.h>
25 #include <vtkTransform.h>
26 
27 namespace mitk
28 {
64  {
65  public:
67  itkFactorylessNewMacro(Self);
68  itkCloneMacro(Self);
69 
70  mitkNewMacro1Param(Self, vtkImageReslice *);
71 
73  void SetWorldGeometry(const PlaneGeometry *geometry)
74  {
75  this->m_WorldGeometry = geometry;
76  this->Modified();
77  }
78 
80  void SetTimeStep(unsigned int timestep) { m_TimeStep = timestep; }
81  unsigned int GetTimeStep() { return m_TimeStep; }
82 
84  void SetComponent(unsigned int component) { m_Component = component; }
85 
89  void SetResliceTransformByGeometry(const BaseGeometry *transform) { this->m_ResliceTransform = transform; }
91  void SetInPlaneResampleExtentByGeometry(bool inPlaneResampleExtentByGeometry)
92  {
93  this->m_InPlaneResampleExtentByGeometry = inPlaneResampleExtentByGeometry;
94  }
95 
97  void SetOutputDimensionality(unsigned int dimension) { this->m_OutputDimension = dimension; }
101  void SetOutputSpacingZDirection(double zSpacing) { this->m_ZSpacing = zSpacing; }
105  void SetOutputExtentZDirection(int zMin, int zMax)
106  {
107  this->m_ZMin = zMin;
108  this->m_ZMax = zMax;
109  }
110 
117  bool GetClippedPlaneBounds(double bounds[6]);
118 
120  bool GetClippedPlaneBounds(const BaseGeometry *boundingGeometry,
121  const PlaneGeometry *planeGeometry,
122  double *bounds);
123 
125  mitk::ScalarType *GetOutputSpacing();
126 
132  vtkImageData *GetVtkOutput()
133  {
134  m_VtkOutputRequested = true;
135  return m_Reslicer->GetOutput();
136  }
137 
144  void SetVtkOutputRequest(bool isRequested) { m_VtkOutputRequested = isRequested; }
148  vtkMatrix4x4 *GetResliceAxes() { return this->m_Reslicer->GetResliceAxes(); }
149  void SetBackgroundLevel(double backgroundLevel) { m_BackgroundLevel = backgroundLevel; }
151  {
152  RESLICE_NEAREST = 0,
153  RESLICE_LINEAR = 1,
154  RESLICE_CUBIC = 3
155  };
156 
158  {
159  this->m_InterpolationMode = interpolation;
160  }
161 
162  protected:
163  ExtractSliceFilter(vtkImageReslice *reslicer = nullptr);
164  ~ExtractSliceFilter() override;
165 
166  void GenerateData() override;
167  void GenerateOutputInformation() override;
168  void GenerateInputRequestedRegion() override;
169 
171  vtkSmartPointer<vtkImageReslice> m_Reslicer;
172 
173  unsigned int m_TimeStep;
174 
175  unsigned int m_OutputDimension;
176 
177  double m_ZSpacing;
178 
179  int m_ZMin;
180 
181  int m_ZMax;
182 
184 
185  bool m_InPlaneResampleExtentByGeometry; // Resampling grid corresponds to: false->image true->worldgeometry
186 
188 
190 
192 
193  unsigned int m_Component;
194 
195  private:
196  BaseGeometry::ConstPointer m_ResliceTransform;
197  /* Axis vectors of the relevant geometry. Set in GenerateOutputInformation() and also used in GenerateData().*/
198  Vector3D m_Right, m_Bottom;
199  /* Bounds of the relevant plane. Set in GenerateOutputInformation() and also used in GenerateData().*/
200  int m_XMin, m_XMax, m_YMin, m_YMax;
201 
202  };
203 }
204 
205 #endif // mitkExtractSliceFilter_h_Included
void SetTimeStep(unsigned int timestep)
Set the time step in the 4D volume.
ResliceInterpolation m_InterpolationMode
vtkMatrix4x4 * GetResliceAxes()
Get the reslices axis matrix. Note: the axis are recalculated when calling SetResliceTransformByGeome...
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
void SetOutputExtentZDirection(int zMin, int zMax)
Set the extent in pixel for direction z manualy. Required if the output dimension is > 2...
void SetVtkOutputRequest(bool isRequested)
double ScalarType
vtkImageData * GetVtkOutput()
Get Output as vtkImageData. Note: SetVtkOutputRequest(true) has to be called at least once before Get...
void SetOutputDimensionality(unsigned int dimension)
Sets the output dimension of the slice.
Superclass of all classes generating some kind of mitk::BaseData.
DataCollection - Class to facilitate loading/accessing structured data.
void SetWorldGeometry(const PlaneGeometry *geometry)
Set the axis where to reslice at.
void SetOutputSpacingZDirection(double zSpacing)
Set the spacing in z direction manually. Required if the outputDimension is > 2.
void SetBackgroundLevel(double backgroundLevel)
void SetResliceTransformByGeometry(const BaseGeometry *transform)
Set a transform for the reslice axes. This transform is needed if the image volume itself is transfor...
const PlaneGeometry * m_WorldGeometry
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Superclass of all classes having one or more Images as input and generating Images as output...
mitk::ScalarType * m_OutPutSpacing
void SetComponent(unsigned int component)
Set the component of an image to be extracted.
Describes a two-dimensional, rectangular plane.
ExtractSliceFilter extracts a 2D abitrary oriented slice from a 3D volume.
vtkSmartPointer< vtkImageReslice > m_Reslicer
void SetInPlaneResampleExtentByGeometry(bool inPlaneResampleExtentByGeometry)
Resampling grid corresponds to: false->image true->worldgeometry.
BaseGeometry Describes the geometry of a data object.
void SetInterpolationMode(ExtractSliceFilter::ResliceInterpolation interpolation)