Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ExtractSliceFilter Class Reference

ExtractSliceFilter extracts a 2D arbitrary oriented slice from a 3D volume. More...

#include <mitkExtractSliceFilter.h>

Inheritance diagram for mitk::ExtractSliceFilter:
Collaboration diagram for mitk::ExtractSliceFilter:

Public Types

enum  ResliceInterpolation { RESLICE_NEAREST , RESLICE_LINEAR , RESLICE_CUBIC }
 
- Public Types inherited from mitk::ImageToImageFilter
typedef Superclass::OutputImageRegionType OutputImageRegionType
 Superclass typedefs. More...
 
typedef mitk::Image InputImageType
 Some convenient typedefs. More...
 
typedef InputImageType::Pointer InputImagePointer
 
typedef InputImageType::ConstPointer InputImageConstPointer
 
typedef SlicedData::RegionType InputImageRegionType
 
- Public Types inherited from mitk::ImageSource
typedef mitk::Image OutputImageType
 Some convenient typedefs. More...
 
typedef OutputImageType OutputType
 
typedef OutputImageType::Pointer OutputImagePointer
 
typedef SlicedData::RegionType OutputImageRegionType
 
- Public Types inherited from mitk::BaseDataSource
typedef BaseData OutputType
 Output data type. More...
 
typedef itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
 Identifier type for named data objects. More...
 

Public Member Functions

 mitkClassMacro (ExtractSliceFilter, ImageToImageFilter)
 
Pointer Clone () const
 
 mitkNewMacro1Param (Self, vtkImageReslice *)
 
void SetWorldGeometry (const PlaneGeometry *geometry)
 Set the plane geometry defining the reslice axis. More...
 
void SetTimeStep (unsigned int timestep)
 Set the time step in the 4D volume. More...
 
unsigned int GetTimeStep ()
 Get the current time step. More...
 
void SetComponent (unsigned int component)
 Set the component of a multi-component image to be extracted. More...
 
void SetResliceTransformByGeometry (const BaseGeometry *transform)
 Set a transform for the reslice axes. More...
 
void SetInPlaneResampleExtentByGeometry (bool inPlaneResampleExtentByGeometry)
 Set whether the resampling grid is derived from image or world geometry. More...
 
void SetOutputDimensionality (unsigned int dimension)
 Set the output dimensionality of the slice. More...
 
void SetOutputSpacingZDirection (double zSpacing)
 Set the spacing in z direction manually. More...
 
void SetOutputExtentZDirection (int zMin, int zMax)
 Set the extent in pixels for the z direction manually. More...
 
bool GetClippedPlaneBounds (double bounds[6])
 Get the bounding box of the slice [xMin, xMax, yMin, yMax, zMin, zMax]. More...
 
bool GetClippedPlaneBounds (const BaseGeometry *boundingGeometry, const PlaneGeometry *planeGeometry, double *bounds)
 Get the bounding box of the slice [xMin, xMax, yMin, yMax, zMin, zMax]. More...
 
mitk::ScalarType * GetOutputSpacing ()
 Get the spacing of the slice. More...
 
vtkImageData * GetVtkOutput ()
 Get the output as vtkImageData. More...
 
void SetVtkOutputRequest (bool isRequested)
 Set VtkOutputRequest to suppress the conversion of the image. More...
 
vtkMatrix4x4 * GetResliceAxes ()
 Get the reslice axes matrix. More...
 
void SetBackgroundLevel (double backgroundLevel)
 Set the background level for areas outside the volume. More...
 
void SetInterpolationMode (ExtractSliceFilter::ResliceInterpolation interpolation)
 Set the interpolation mode for reslicing. More...
 
- Public Member Functions inherited from mitk::ImageToImageFilter
 mitkClassMacro (ImageToImageFilter, ImageSource)
 
Pointer Clone () const
 
virtual void SetInput (const InputImageType *image)
 Set the image input of this process object. More...
 
virtual void SetInput (unsigned int idx, const InputImageType *image)
 Set the image input at the specified index. More...
 
InputImageType * GetInput (void)
 Get the input image (non-const). More...
 
InputImageType * GetInput (unsigned int idx)
 Get the input image at the specified index (non-const). More...
 
const InputImageType * GetInput (void) const
 Get the input image (const). More...
 
const InputImageType * GetInput (unsigned int idx) const
 Get the input image at the specified index (const). More...
 
- Public Member Functions inherited from mitk::ImageSource
 mitkClassMacro (ImageSource, BaseDataSource)
 
Pointer Clone () const
 
mitkBaseDataSourceGetOutputDeclarations itk::DataObject::Pointer MakeOutput (DataObjectPointerArraySizeType idx) override
 Get the output data of this image source object. More...
 
itk::DataObject::Pointer MakeOutput (const DataObjectIdentifierType &name) override
 
virtual vtkImageData * GetVtkImageData ()
 Get the output as VTK image data (non-const version). More...
 
virtual const vtkImageData * GetVtkImageData () const
 Get the output as VTK image data (const version). More...
 
- Public Member Functions inherited from mitk::BaseDataSource
 mitkClassMacroItkParent (BaseDataSource, itk::ProcessObject)
 
OutputType * GetOutput ()
 
const OutputType * GetOutput () const
 
OutputType * GetOutput (DataObjectPointerArraySizeType idx)
 
const OutputType * GetOutput (DataObjectPointerArraySizeType idx) const
 
virtual void GraftOutput (OutputType *output)
 Graft the specified BaseData onto this BaseDataSource's output. More...
 
virtual void GraftOutput (const DataObjectIdentifierType &key, OutputType *output)
 Graft the specified base data object onto a named output. More...
 
virtual void GraftNthOutput (unsigned int idx, OutputType *output)
 Graft the specified base data object onto this BaseDataSource's idx'th output. More...
 
bool Updating () const
 Check whether the pipeline is currently executing. More...
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from mitk::ImageToImageFilter
static Pointer New ()
 Method for creation through the object factory. More...
 
- Static Public Member Functions inherited from mitk::ImageSource
static Pointer New ()
 Method for creation through the object factory. More...
 

Protected Member Functions

 ExtractSliceFilter (vtkImageReslice *reslicer=nullptr)
 Constructor. More...
 
 ~ExtractSliceFilter () override
 Destructor. More...
 
void GenerateData () override
 Perform the actual reslicing. More...
 
void GenerateOutputInformation () override
 Compute output information (spacing, origin, extent) based on input and world geometry. More...
 
void GenerateInputRequestedRegion () override
 Set the requested region on the input image. More...
 
- Protected Member Functions inherited from mitk::ImageToImageFilter
 ImageToImageFilter ()
 
 ~ImageToImageFilter () override
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 Print self information to the given stream. More...
 
void GenerateInputRequestedRegion () override
 Determine the input requested region to produce the output requested region. More...
 
- Protected Member Functions inherited from mitk::ImageSource
 ImageSource ()
 
 ~ImageSource () override
 
void GenerateData () override
 A version of GenerateData() specific for image processing filters. More...
 
virtual void ThreadedGenerateData (const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId)
 If an imaging filter can be implemented as a multithreaded algorithm, the filter will provide an implementation of ThreadedGenerateData(). More...
 
void PrepareOutputs () override
 This method is intentionally left blank. More...
 
virtual void AllocateOutputs ()
 The GenerateData method normally allocates the buffers for all of the outputs of a filter. More...
 
virtual void BeforeThreadedGenerateData ()
 If an imaging filter needs to perform processing after the buffer has been allocated but before threads are spawned, the filter can provide an implementation for BeforeThreadedGenerateData(). More...
 
virtual void AfterThreadedGenerateData ()
 If an imaging filter needs to perform processing after all processing threads have completed, the filter can provide an implementation for AfterThreadedGenerateData(). More...
 
virtual unsigned int SplitRequestedRegion (unsigned int i, unsigned int num, OutputImageRegionType &splitRegion)
 Split the output's RequestedRegion into "num" pieces, returning region "i" as "splitRegion". More...
 
- Protected Member Functions inherited from mitk::BaseDataSource
 BaseDataSource ()
 Constructor. More...
 
 ~BaseDataSource () override
 Destructor. More...
 

Protected Attributes

PlaneGeometry::ConstPointer m_WorldGeometry
 
vtkSmartPointer< vtkImageReslice > m_Reslicer
 
unsigned int m_TimeStep
 
unsigned int m_OutputDimension
 
double m_ZSpacing
 
int m_ZMin
 
int m_ZMax
 
ResliceInterpolation m_InterpolationMode
 
bool m_InPlaneResampleExtentByGeometry
 
mitk::ScalarType * m_OutPutSpacing
 
bool m_VtkOutputRequested
 
double m_BackgroundLevel
 
unsigned int m_Component
 

Additional Inherited Members

- Static Protected Member Functions inherited from mitk::ImageSource
static itk::ITK_THREAD_RETURN_TYPE ThreaderCallback (void *arg)
 Static function used as a "callback" by the MultiThreader. More...
 
- Static Protected Member Functions inherited from mitk::BaseDataSource
static Pointer New ()
 

Detailed Description

ExtractSliceFilter extracts a 2D arbitrary oriented slice from a 3D volume.

The filter can reslice in all orthogonal planes such as sagittal, coronal and axial, and is also able to reslice an arbitrary oriented oblique plane. Curved planes are specified via an AbstractTransformGeometry as the input worldgeometry.

Additionally the filter extracts the specified component of a multi-component input image. This is done only if the caller requests an mitk::Image output ('m_VtkOutputRequested' set to false). The default component to be extracted is '0'.

The convenient workflow is:

  1. Set an image as input.
  2. Set the worldPlaneGeometry. This defines a grid where the slice is being extracted
  3. And then start the pipeline.

There are a few more properties that can be set to modify the behavior of the slicing. The properties are:

  • interpolation mode either Nearestneighbor, Linear or Cubic.
  • a transform this is a convenient way to adapt the reslice axis for the case that the image is transformed e.g. rotated.
  • time step the time step in a times volume.
  • the component to extract from a multi-component input image
  • vtkoutputrequested, to define whether an mitk::image should be initialized
  • resample by geometry whether the resampling grid corresponds to the specs of the worldgeometry or is directly derived from the input image

By default the properties are set to:

  • interpolation mode Nearestneighbor.
  • a transform nullptr (No transform is set).
  • time step 0.
  • component 0.
  • resample by geometry false (Corresponds to input image).

Definition at line 63 of file mitkExtractSliceFilter.h.

Member Enumeration Documentation

◆ ResliceInterpolation

Enumerator
RESLICE_NEAREST 
RESLICE_LINEAR 
RESLICE_CUBIC 

Definition at line 230 of file mitkExtractSliceFilter.h.

Constructor & Destructor Documentation

◆ ExtractSliceFilter()

mitk::ExtractSliceFilter::ExtractSliceFilter ( vtkImageReslice *  reslicer = nullptr)
protected

Constructor.

Parameters
reslicerOptional custom vtkImageReslice instance. If nullptr, a default one is created.

◆ ~ExtractSliceFilter()

mitk::ExtractSliceFilter::~ExtractSliceFilter ( )
overrideprotected

Destructor.

Member Function Documentation

◆ Clone()

Pointer mitk::ExtractSliceFilter::Clone ( ) const

◆ GenerateData()

void mitk::ExtractSliceFilter::GenerateData ( )
overrideprotected

Perform the actual reslicing.

◆ GenerateInputRequestedRegion()

void mitk::ExtractSliceFilter::GenerateInputRequestedRegion ( )
overrideprotected

Set the requested region on the input image.

◆ GenerateOutputInformation()

void mitk::ExtractSliceFilter::GenerateOutputInformation ( )
overrideprotected

Compute output information (spacing, origin, extent) based on input and world geometry.

◆ GetClippedPlaneBounds() [1/2]

bool mitk::ExtractSliceFilter::GetClippedPlaneBounds ( const BaseGeometry *  boundingGeometry,
const PlaneGeometry *  planeGeometry,
double *  bounds 
)

Get the bounding box of the slice [xMin, xMax, yMin, yMax, zMin, zMax].

Parameters
boundingGeometryThe bounding geometry of the volume.
planeGeometryThe plane geometry defining the slice.
boundsOutput array of six doubles: [xMin, xMax, yMin, yMax, zMin, zMax].
Returns
true if bounds were successfully computed, false otherwise.

◆ GetClippedPlaneBounds() [2/2]

bool mitk::ExtractSliceFilter::GetClippedPlaneBounds ( double  bounds[6])

Get the bounding box of the slice [xMin, xMax, yMin, yMax, zMin, zMax].

The method uses the input of the filter to calculate the bounds. It is recommended to use GetClippedPlaneBounds(const BaseGeometry*, const PlaneGeometry*, double*) if you are not sure about the input.

Parameters
boundsOutput array of six doubles: [xMin, xMax, yMin, yMax, zMin, zMax].
Returns
true if bounds were successfully computed, false otherwise.

◆ GetOutputSpacing()

mitk::ScalarType* mitk::ExtractSliceFilter::GetOutputSpacing ( )

Get the spacing of the slice.

Returns
Pointer to an array of two mitk::ScalarType values representing the x and y spacing.

◆ GetResliceAxes()

vtkMatrix4x4* mitk::ExtractSliceFilter::GetResliceAxes ( )
inline

Get the reslice axes matrix.

Note
The axes are recalculated when calling SetResliceTransformByGeometry.
Returns
The 4x4 reslice axes matrix.

Definition at line 222 of file mitkExtractSliceFilter.h.

◆ GetTimeStep()

unsigned int mitk::ExtractSliceFilter::GetTimeStep ( )
inline

Get the current time step.

Returns
The time step index currently set.

Definition at line 98 of file mitkExtractSliceFilter.h.

◆ GetVtkOutput()

vtkImageData* mitk::ExtractSliceFilter::GetVtkOutput ( )
inline

Get the output as vtkImageData.

Note
SetVtkOutputRequest(true) has to be called at least once before GetVtkOutput(). Otherwise the output is empty for the first update step.
Returns
The resliced output as vtkImageData.

Definition at line 197 of file mitkExtractSliceFilter.h.

◆ mitkClassMacro()

mitk::ExtractSliceFilter::mitkClassMacro ( ExtractSliceFilter  ,
ImageToImageFilter   
)

◆ mitkNewMacro1Param()

mitk::ExtractSliceFilter::mitkNewMacro1Param ( Self  ,
vtkImageReslice *   
)

◆ New()

static Pointer mitk::ExtractSliceFilter::New ( )
static

◆ SetBackgroundLevel()

void mitk::ExtractSliceFilter::SetBackgroundLevel ( double  backgroundLevel)
inline

Set the background level for areas outside the volume.

Parameters
backgroundLevelThe background intensity value.

Definition at line 229 of file mitkExtractSliceFilter.h.

◆ SetComponent()

void mitk::ExtractSliceFilter::SetComponent ( unsigned int  component)
inline

Set the component of a multi-component image to be extracted.

Parameters
componentThe zero-based component index.

Definition at line 105 of file mitkExtractSliceFilter.h.

◆ SetInPlaneResampleExtentByGeometry()

void mitk::ExtractSliceFilter::SetInPlaneResampleExtentByGeometry ( bool  inPlaneResampleExtentByGeometry)
inline

Set whether the resampling grid is derived from image or world geometry.

Parameters
inPlaneResampleExtentByGeometryIf false, resampling grid corresponds to the image; if true, it corresponds to the world geometry.

Definition at line 122 of file mitkExtractSliceFilter.h.

◆ SetInterpolationMode()

void mitk::ExtractSliceFilter::SetInterpolationMode ( ExtractSliceFilter::ResliceInterpolation  interpolation)
inline

Set the interpolation mode for reslicing.

Parameters
interpolationThe interpolation mode (RESLICE_NEAREST, RESLICE_LINEAR, or RESLICE_CUBIC).

Definition at line 242 of file mitkExtractSliceFilter.h.

◆ SetOutputDimensionality()

void mitk::ExtractSliceFilter::SetOutputDimensionality ( unsigned int  dimension)
inline

Set the output dimensionality of the slice.

Parameters
dimensionThe output dimension (typically 2 for a slice).

Definition at line 132 of file mitkExtractSliceFilter.h.

◆ SetOutputExtentZDirection()

void mitk::ExtractSliceFilter::SetOutputExtentZDirection ( int  zMin,
int  zMax 
)
inline

Set the extent in pixels for the z direction manually.

Required if the output dimension is > 2.

Parameters
zMinMinimum z extent.
zMaxMaximum z extent.

Definition at line 151 of file mitkExtractSliceFilter.h.

◆ SetOutputSpacingZDirection()

void mitk::ExtractSliceFilter::SetOutputSpacingZDirection ( double  zSpacing)
inline

Set the spacing in z direction manually.

Required if the output dimension is > 2.

Parameters
zSpacingThe spacing value in z direction.

Definition at line 141 of file mitkExtractSliceFilter.h.

◆ SetResliceTransformByGeometry()

void mitk::ExtractSliceFilter::SetResliceTransformByGeometry ( const BaseGeometry *  transform)
inline

Set a transform for the reslice axes.

This transform is needed if the image volume itself is transformed (affects the reslice axis).

Parameters
transformThe BaseGeometry whose transform is used.

Definition at line 114 of file mitkExtractSliceFilter.h.

◆ SetTimeStep()

void mitk::ExtractSliceFilter::SetTimeStep ( unsigned int  timestep)
inline

Set the time step in the 4D volume.

Parameters
timestepThe time step index to extract.

Definition at line 91 of file mitkExtractSliceFilter.h.

◆ SetVtkOutputRequest()

void mitk::ExtractSliceFilter::SetVtkOutputRequest ( bool  isRequested)
inline

Set VtkOutputRequest to suppress the conversion of the image.

It is suggested to use this with GetVtkOutput().

Note
SetVtkOutputRequest(true) has to be called at least once before GetVtkOutput(). Otherwise the output is empty for the first update step.
Parameters
isRequestedIf true, output will be provided as vtkImageData.

Definition at line 213 of file mitkExtractSliceFilter.h.

◆ SetWorldGeometry()

void mitk::ExtractSliceFilter::SetWorldGeometry ( const PlaneGeometry *  geometry)
inline

Set the plane geometry defining the reslice axis.

Parameters
geometryThe PlaneGeometry that defines where to reslice.

Definition at line 77 of file mitkExtractSliceFilter.h.

Member Data Documentation

◆ m_BackgroundLevel

double mitk::ExtractSliceFilter::m_BackgroundLevel
protected

Definition at line 288 of file mitkExtractSliceFilter.h.

◆ m_Component

unsigned int mitk::ExtractSliceFilter::m_Component
protected

Definition at line 290 of file mitkExtractSliceFilter.h.

◆ m_InPlaneResampleExtentByGeometry

bool mitk::ExtractSliceFilter::m_InPlaneResampleExtentByGeometry
protected

Definition at line 282 of file mitkExtractSliceFilter.h.

◆ m_InterpolationMode

ResliceInterpolation mitk::ExtractSliceFilter::m_InterpolationMode
protected

Definition at line 280 of file mitkExtractSliceFilter.h.

◆ m_OutputDimension

unsigned int mitk::ExtractSliceFilter::m_OutputDimension
protected

Definition at line 272 of file mitkExtractSliceFilter.h.

◆ m_OutPutSpacing

mitk::ScalarType* mitk::ExtractSliceFilter::m_OutPutSpacing
protected

Definition at line 284 of file mitkExtractSliceFilter.h.

◆ m_Reslicer

vtkSmartPointer<vtkImageReslice> mitk::ExtractSliceFilter::m_Reslicer
protected

Definition at line 268 of file mitkExtractSliceFilter.h.

◆ m_TimeStep

unsigned int mitk::ExtractSliceFilter::m_TimeStep
protected

Definition at line 270 of file mitkExtractSliceFilter.h.

◆ m_VtkOutputRequested

bool mitk::ExtractSliceFilter::m_VtkOutputRequested
protected

Definition at line 286 of file mitkExtractSliceFilter.h.

◆ m_WorldGeometry

PlaneGeometry::ConstPointer mitk::ExtractSliceFilter::m_WorldGeometry
protected

Definition at line 267 of file mitkExtractSliceFilter.h.

◆ m_ZMax

int mitk::ExtractSliceFilter::m_ZMax
protected

Definition at line 278 of file mitkExtractSliceFilter.h.

◆ m_ZMin

int mitk::ExtractSliceFilter::m_ZMin
protected

Definition at line 276 of file mitkExtractSliceFilter.h.

◆ m_ZSpacing

double mitk::ExtractSliceFilter::m_ZSpacing
protected

Definition at line 274 of file mitkExtractSliceFilter.h.


The documentation for this class was generated from the following file: