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

Crops or masks an image using a bounding box defined by GeometryData. More...

#include <mitkBoundingShapeCropper.h>

Inheritance diagram for mitk::BoundingShapeCropper:
Collaboration diagram for mitk::BoundingShapeCropper:

Public Member Functions

 mitkClassMacro (BoundingShapeCropper, ImageToImageFilter)
 
Pointer Clone () const
 
void SetGeometry (const mitk::GeometryData *geometry)
 Set the geometry of the bounding object used for cropping/masking. More...
 
virtual void SetOutsideValue (ScalarType _arg)
 Set the pixel value assigned to voxels outside the bounding box during masking. More...
 
virtual ScalarType GetOutsideValue ()
 Get the current outside pixel value used for masking. More...
 
virtual void SetUseWholeInputRegion (bool _arg)
 Set whether the full input region is preserved (masking mode). More...
 
virtual bool GetUseWholeInputRegion ()
 Get whether masking mode is active. More...
 
virtual void SetCurrentTimeStep (ScalarType _arg)
 Set the time step to process for 4D images. More...
 
virtual ScalarType GetCurrentTimeStep ()
 Get the current time step index. More...
 
virtual void SetUseCropTimeStepOnly (bool _arg)
 Set whether to process only a single time step. More...
 
virtual bool GetUseCropTimeStepOnly ()
 Get whether only a single time step is processed. 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

 BoundingShapeCropper ()
 
 ~BoundingShapeCropper () override
 
virtual const PixelType GetOutputPixelType ()
 
void GenerateInputRequestedRegion () override
 Reimplemented from ImageToImageFilter. More...
 
void GenerateOutputInformation () override
 
void GenerateData () override
 
template<typename TPixel , unsigned int VImageDimension>
void CutImage (itk::Image< TPixel, VImageDimension > *inputItkImage, int timeStep)
 Template Function for cropping and masking images with scalar pixel type. More...
 
virtual void ComputeData (mitk::Image *input3D, int boTimeStep)
 Process the image and create the output. 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...
 

Additional Inherited Members

- 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...
 
- 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

Crops or masks an image using a bounding box defined by GeometryData.

This filter takes an mitk::Image and an mitk::GeometryData as inputs and produces a cropped or masked image as output.

Two modes of operation are supported:

  • Cropping (UseWholeInputRegion = false): The output image is reduced to the size of the bounding box.
  • Masking (UseWholeInputRegion = true): The output image retains the original dimensions, but pixels outside the bounding box are set to the OutsideValue.

For 4D images, optionally only a single time step can be processed via UseCropTimeStepOnly and CurrentTimeStep.

Precondition
The input image and a valid GeometryData must be set before calling Update().
See also
GeometryData, ImageToImageFilter, BoundingShapeInteractor

Definition at line 47 of file mitkBoundingShapeCropper.h.

Constructor & Destructor Documentation

◆ BoundingShapeCropper()

mitk::BoundingShapeCropper::BoundingShapeCropper ( )
protected

◆ ~BoundingShapeCropper()

mitk::BoundingShapeCropper::~BoundingShapeCropper ( )
overrideprotected

Member Function Documentation

◆ Clone()

Pointer mitk::BoundingShapeCropper::Clone ( ) const

◆ ComputeData()

virtual void mitk::BoundingShapeCropper::ComputeData ( mitk::Image *  input3D,
int  boTimeStep 
)
protectedvirtual

Process the image and create the output.

◆ CutImage()

template<typename TPixel , unsigned int VImageDimension>
void mitk::BoundingShapeCropper::CutImage ( itk::Image< TPixel, VImageDimension > *  inputItkImage,
int  timeStep 
)
protected

Template Function for cropping and masking images with scalar pixel type.

◆ GenerateData()

void mitk::BoundingShapeCropper::GenerateData ( )
overrideprotected

◆ GenerateInputRequestedRegion()

void mitk::BoundingShapeCropper::GenerateInputRequestedRegion ( )
overrideprotected

Reimplemented from ImageToImageFilter.

◆ GenerateOutputInformation()

void mitk::BoundingShapeCropper::GenerateOutputInformation ( )
overrideprotected

◆ GetCurrentTimeStep()

virtual ScalarType mitk::BoundingShapeCropper::GetCurrentTimeStep ( )
virtual

Get the current time step index.

Returns
The zero-based time step index.

◆ GetOutputPixelType()

virtual const PixelType mitk::BoundingShapeCropper::GetOutputPixelType ( )
protectedvirtual

◆ GetOutsideValue()

virtual ScalarType mitk::BoundingShapeCropper::GetOutsideValue ( )
virtual

Get the current outside pixel value used for masking.

Returns
The scalar value assigned to pixels outside the bounding box.

◆ GetUseCropTimeStepOnly()

virtual bool mitk::BoundingShapeCropper::GetUseCropTimeStepOnly ( )
virtual

Get whether only a single time step is processed.

Returns
true if only the CurrentTimeStep is processed.

◆ GetUseWholeInputRegion()

virtual bool mitk::BoundingShapeCropper::GetUseWholeInputRegion ( )
virtual

Get whether masking mode is active.

Returns
true if masking mode is active, false for cropping mode.

◆ mitkClassMacro()

mitk::BoundingShapeCropper::mitkClassMacro ( BoundingShapeCropper  ,
ImageToImageFilter   
)

◆ New()

static Pointer mitk::BoundingShapeCropper::New ( )
static

◆ SetCurrentTimeStep()

virtual void mitk::BoundingShapeCropper::SetCurrentTimeStep ( ScalarType  _arg)
virtual

Set the time step to process for 4D images.

Only relevant when UseCropTimeStepOnly is true.

Parameters
[in]_argThe zero-based time step index.

◆ SetGeometry()

void mitk::BoundingShapeCropper::SetGeometry ( const mitk::GeometryData *  geometry)

Set the geometry of the bounding object used for cropping/masking.

Parameters
[in]geometryThe GeometryData defining the bounding box region.
Precondition
geometry is not null and has a valid BaseGeometry.

◆ SetOutsideValue()

virtual void mitk::BoundingShapeCropper::SetOutsideValue ( ScalarType  _arg)
virtual

Set the pixel value assigned to voxels outside the bounding box during masking.

Only used when UseWholeInputRegion is true (masking mode). Default: 0.

Parameters
[in]_argThe scalar value for outside pixels.

◆ SetUseCropTimeStepOnly()

virtual void mitk::BoundingShapeCropper::SetUseCropTimeStepOnly ( bool  _arg)
virtual

Set whether to process only a single time step.

Parameters
[in]_argIf true, only the time step specified by CurrentTimeStep is cropped/masked. If false, all time steps are processed.

◆ SetUseWholeInputRegion()

virtual void mitk::BoundingShapeCropper::SetUseWholeInputRegion ( bool  _arg)
virtual

Set whether the full input region is preserved (masking mode).

Parameters
[in]_argIf true, the output has the same dimensions as the input and outside pixels are set to OutsideValue (masking). If false, the output is cropped to the bounding box size.

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