Medical Imaging Interaction Toolkit  2018.4.99-ae21cdc4
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  if (geometry != m_WorldGeometry)
76  {
77  this->m_WorldGeometry = geometry;
78  this->Modified();
79  }
80  }
81 
83  void SetTimeStep(unsigned int timestep) { m_TimeStep = timestep; }
84  unsigned int GetTimeStep() { return m_TimeStep; }
85 
87  void SetComponent(unsigned int component) { m_Component = component; }
88 
92  void SetResliceTransformByGeometry(const BaseGeometry *transform) { this->m_ResliceTransform = transform; }
94  void SetInPlaneResampleExtentByGeometry(bool inPlaneResampleExtentByGeometry)
95  {
96  this->m_InPlaneResampleExtentByGeometry = inPlaneResampleExtentByGeometry;
97  }
98 
100  void SetOutputDimensionality(unsigned int dimension) { this->m_OutputDimension = dimension; }
104  void SetOutputSpacingZDirection(double zSpacing) { this->m_ZSpacing = zSpacing; }
108  void SetOutputExtentZDirection(int zMin, int zMax)
109  {
110  this->m_ZMin = zMin;
111  this->m_ZMax = zMax;
112  }
113 
120  bool GetClippedPlaneBounds(double bounds[6]);
121 
123  bool GetClippedPlaneBounds(const BaseGeometry *boundingGeometry,
124  const PlaneGeometry *planeGeometry,
125  double *bounds);
126 
128  mitk::ScalarType *GetOutputSpacing();
129 
135  vtkImageData *GetVtkOutput()
136  {
137  m_VtkOutputRequested = true;
138  return m_Reslicer->GetOutput();
139  }
140 
147  void SetVtkOutputRequest(bool isRequested) { m_VtkOutputRequested = isRequested; }
151  vtkMatrix4x4 *GetResliceAxes() { return this->m_Reslicer->GetResliceAxes(); }
152  void SetBackgroundLevel(double backgroundLevel) { m_BackgroundLevel = backgroundLevel; }
154  {
155  RESLICE_NEAREST = 0,
156  RESLICE_LINEAR = 1,
157  RESLICE_CUBIC = 3
158  };
159 
161  {
162  this->m_InterpolationMode = interpolation;
163  }
164 
165  protected:
166  ExtractSliceFilter(vtkImageReslice *reslicer = nullptr);
167  ~ExtractSliceFilter() override;
168 
169  void GenerateData() override;
170  void GenerateOutputInformation() override;
171  void GenerateInputRequestedRegion() override;
172 
174  vtkSmartPointer<vtkImageReslice> m_Reslicer;
175 
176  unsigned int m_TimeStep;
177 
178  unsigned int m_OutputDimension;
179 
180  double m_ZSpacing;
181 
182  int m_ZMin;
183 
184  int m_ZMax;
185 
187 
188  bool m_InPlaneResampleExtentByGeometry; // Resampling grid corresponds to: false->image true->worldgeometry
189 
191 
193 
195 
196  unsigned int m_Component;
197 
198  private:
199  BaseGeometry::ConstPointer m_ResliceTransform;
200  /* Axis vectors of the relevant geometry. Set in GenerateOutputInformation() and also used in GenerateData().*/
201  Vector3D m_Right, m_Bottom;
202  /* Bounds of the relevant plane. Set in GenerateOutputInformation() and also used in GenerateData().*/
203  int m_XMin, m_XMax, m_YMin, m_YMax;
204 
205  };
206 }
207 
208 #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)
PlaneGeometry::ConstPointer m_WorldGeometry
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...
#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)