Medical Imaging Interaction Toolkit  2023.04.00
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
14 #define mitkExtractSliceFilter_h
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
mitk::ExtractSliceFilter::SetOutputDimensionality
void SetOutputDimensionality(unsigned int dimension)
Sets the output dimension of the slice.
Definition: mitkExtractSliceFilter.h:100
mitkImageToImageFilter.h
mitk::ExtractSliceFilter::m_OutPutSpacing
mitk::ScalarType * m_OutPutSpacing
Definition: mitkExtractSliceFilter.h:190
mitk::ExtractSliceFilter::m_ZMax
int m_ZMax
Definition: mitkExtractSliceFilter.h:184
mitk::ExtractSliceFilter::m_InterpolationMode
ResliceInterpolation m_InterpolationMode
Definition: mitkExtractSliceFilter.h:186
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::ExtractSliceFilter::m_Component
unsigned int m_Component
Definition: mitkExtractSliceFilter.h:196
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
itk::SmartPointer< const Self >
mitk::ExtractSliceFilter::SetOutputSpacingZDirection
void SetOutputSpacingZDirection(double zSpacing)
Set the spacing in z direction manually. Required if the outputDimension is > 2.
Definition: mitkExtractSliceFilter.h:104
mitk::ExtractSliceFilter::m_TimeStep
unsigned int m_TimeStep
Definition: mitkExtractSliceFilter.h:176
mitk::ExtractSliceFilter::GetResliceAxes
vtkMatrix4x4 * GetResliceAxes()
Get the reslices axis matrix. Note: the axis are recalculated when calling SetResliceTransformByGeome...
Definition: mitkExtractSliceFilter.h:151
mitk::ExtractSliceFilter::SetResliceTransformByGeometry
void SetResliceTransformByGeometry(const BaseGeometry *transform)
Set a transform for the reslice axes. This transform is needed if the image volume itself is transfor...
Definition: mitkExtractSliceFilter.h:92
mitk::ExtractSliceFilter::m_WorldGeometry
PlaneGeometry::ConstPointer m_WorldGeometry
Definition: mitkExtractSliceFilter.h:173
mitk::ExtractSliceFilter
ExtractSliceFilter extracts a 2D arbitrary oriented slice from a 3D volume.
Definition: mitkExtractSliceFilter.h:63
mitk::ExtractSliceFilter::SetVtkOutputRequest
void SetVtkOutputRequest(bool isRequested)
Definition: mitkExtractSliceFilter.h:147
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::ExtractSliceFilter::m_InPlaneResampleExtentByGeometry
bool m_InPlaneResampleExtentByGeometry
Definition: mitkExtractSliceFilter.h:188
mitk::BaseDataSource
Superclass of all classes generating some kind of mitk::BaseData.
Definition: mitkBaseDataSource.h:71
mitk::ExtractSliceFilter::GetTimeStep
unsigned int GetTimeStep()
Definition: mitkExtractSliceFilter.h:84
mitk::ExtractSliceFilter::ResliceInterpolation
ResliceInterpolation
Definition: mitkExtractSliceFilter.h:153
mitk::ExtractSliceFilter::SetBackgroundLevel
void SetBackgroundLevel(double backgroundLevel)
Definition: mitkExtractSliceFilter.h:152
mitk::Vector< ScalarType, 3 >
MitkCoreExports.h
mitk::BaseGeometry
BaseGeometry Describes the geometry of a data object.
Definition: mitkBaseGeometry.h:94
mitk::ExtractSliceFilter::m_ZMin
int m_ZMin
Definition: mitkExtractSliceFilter.h:182
mitk::ExtractSliceFilter::m_BackgroundLevel
double m_BackgroundLevel
Definition: mitkExtractSliceFilter.h:194
mitk::ExtractSliceFilter::SetWorldGeometry
void SetWorldGeometry(const PlaneGeometry *geometry)
Set the axis where to reslice at.
Definition: mitkExtractSliceFilter.h:73
mitk::ExtractSliceFilter::m_OutputDimension
unsigned int m_OutputDimension
Definition: mitkExtractSliceFilter.h:178
mitk::ExtractSliceFilter::SetOutputExtentZDirection
void SetOutputExtentZDirection(int zMin, int zMax)
Set the extent in pixel for direction z manually. Required if the output dimension is > 2.
Definition: mitkExtractSliceFilter.h:108
mitk::ExtractSliceFilter::GetVtkOutput
vtkImageData * GetVtkOutput()
Get Output as vtkImageData. Note: SetVtkOutputRequest(true) has to be called at least once before Get...
Definition: mitkExtractSliceFilter.h:135
mitk::ExtractSliceFilter::m_Reslicer
vtkSmartPointer< vtkImageReslice > m_Reslicer
Definition: mitkExtractSliceFilter.h:174
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::ExtractSliceFilter::SetInPlaneResampleExtentByGeometry
void SetInPlaneResampleExtentByGeometry(bool inPlaneResampleExtentByGeometry)
Resampling grid corresponds to: false->image true->worldgeometry.
Definition: mitkExtractSliceFilter.h:94
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::ExtractSliceFilter::SetTimeStep
void SetTimeStep(unsigned int timestep)
Set the time step in the 4D volume.
Definition: mitkExtractSliceFilter.h:83
mitk::ImageToImageFilter
Superclass of all classes having one or more Images as input and generating Images as output.
Definition: mitkImageToImageFilter.h:25
mitk::ExtractSliceFilter::SetInterpolationMode
void SetInterpolationMode(ExtractSliceFilter::ResliceInterpolation interpolation)
Definition: mitkExtractSliceFilter.h:160
mitk::ExtractSliceFilter::SetComponent
void SetComponent(unsigned int component)
Set the component of an image to be extracted.
Definition: mitkExtractSliceFilter.h:87
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20
mitk::ExtractSliceFilter::m_VtkOutputRequested
bool m_VtkOutputRequested
Definition: mitkExtractSliceFilter.h:192
mitk::ExtractSliceFilter::m_ZSpacing
double m_ZSpacing
Definition: mitkExtractSliceFilter.h:180