Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
Medical Imaging Interaction Toolkit
mitk::SegmentationInterpolationController Class Reference

Generates interpolations of 2D slices. More...

#include <mitkSegmentationInterpolationController.h>

Inheritance diagram for mitk::SegmentationInterpolationController:
Collaboration diagram for mitk::SegmentationInterpolationController:

Classes

class  SetChangedSliceOptions
 Protected class of mitk::SegmentationInterpolationController. Don't use (you shouldn't be able to do so)! More...
 

Public Member Functions

 mitkClassMacroItkParent (SegmentationInterpolationController, itk::Object)
 
Pointer Clone () const
 
void BlockModified (bool)
 Block reaction to an images Modified() events. More...
 
void SetSegmentationVolume (const Image *segmentation)
 Initialize with a whole volume. More...
 
void SetReferenceVolume (const Image *segmentation)
 Set a reference image (original patient image) - optional. More...
 
void SetChangedSlice (const Image *sliceDiff, unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep)
 Update after changing a single slice. More...
 
void SetChangedVolume (const Image *sliceDiff, unsigned int timeStep)
 
Image::Pointer Interpolate (unsigned int sliceDimension, unsigned int sliceIndex, const mitk::PlaneGeometry *currentPlane, unsigned int timeStep, mitk::ShapeBasedInterpolationAlgorithm::Pointer algorithm=nullptr)
 Generates an interpolated image for the given slice. More...
 
void OnImageModified (const itk::EventObject &)
 
void Activate2DInterpolation (bool)
 
void EnableSliceImageCache ()
 
void DisableSliceImageCache ()
 

Static Public Member Functions

static Pointer New ()
 
static SegmentationInterpolationControllerInterpolatorForImage (const Image *)
 Find interpolator for a given image. More...
 
static SegmentationInterpolationControllerGetInstance ()
 Get existing instance or create a new one. More...
 

Protected Types

typedef std::vector< unsigned int > DirtyVectorType
 
typedef std::vector< std::vector< DirtyVectorType > > TimeResolvedDirtyVectorType
 
typedef std::map< const Image *, SegmentationInterpolationController * > InterpolatorMapType
 

Protected Member Functions

 SegmentationInterpolationController ()
 
 ~SegmentationInterpolationController () override
 
template<typename DATATYPE >
void ScanChangedSlice (const itk::Image< DATATYPE, 2 > *, const SetChangedSliceOptions &options)
 internal scan of a single slice More...
 
template<typename TPixel , unsigned int VImageDimension>
void ScanChangedVolume (const itk::Image< TPixel, VImageDimension > *, unsigned int timeStep)
 
template<typename DATATYPE >
void ScanWholeVolume (const itk::Image< DATATYPE, 3 > *, const Image *volume, unsigned int timeStep)
 
void PrintStatus ()
 
mitk::Image::Pointer ExtractSlice (const PlaneGeometry *planeGeometry, unsigned int sliceIndex, unsigned int timeStep, bool cache=false)
 

Protected Attributes

TimeResolvedDirtyVectorType m_SegmentationCountInSlice
 
Image::ConstPointer m_Segmentation
 
std::pair< unsigned long, bool > m_SegmentationModifiedObserverTag
 
Image::ConstPointer m_ReferenceImage
 
bool m_BlockModified
 
bool m_2DInterpolationActivated
 
bool m_EnableSliceImageCache
 
std::map< std::pair< unsigned int, unsigned int >, Image::Pointerm_SliceImageCache
 
std::mutex m_SliceImageCacheMutex
 

Static Protected Attributes

static InterpolatorMapType s_InterpolatorForImage
 

Detailed Description

Generates interpolations of 2D slices.

See also
QmitkSlicesInterpolator
QmitkInteractiveSegmentation

This class keeps track of the contents of a 3D segmentation image.

Attention
mitk::SegmentationInterpolationController assumes that the image contains pixel values of 0 and 1.

After you set the segmentation image using SetSegmentationVolume(), the whole image is scanned for pixels other than 0. SegmentationInterpolationController registers as an observer to the segmentation image, and repeats the scan whenvever the image is modified.

You can prevent this (time consuming) scan if you do the changes slice-wise and send difference images to SegmentationInterpolationController. For this purpose SetChangedSlice() should be used. mitk::OverwriteImageFilter already does this every time it changes a slice of an image. There is a static method InterpolatorForImage(), which can be used to find out if there already is an interpolator instance for a specified image. OverwriteImageFilter uses this to get to know its interpolator.

SegmentationInterpolationController needs to maintain some information about the image slices (in every dimension). This information is stored internally in m_SegmentationCountInSlice, which is basically three std::vectors (one for each dimension). Each item describes one image dimension, each vector item holds the count of pixels in "its" slice.

$Author$

Definition at line 65 of file mitkSegmentationInterpolationController.h.

Member Typedef Documentation

◆ DirtyVectorType

typedef std::vector<unsigned int> mitk::SegmentationInterpolationController::DirtyVectorType
protected

Definition at line 191 of file mitkSegmentationInterpolationController.h.

◆ InterpolatorMapType

◆ TimeResolvedDirtyVectorType

Constructor & Destructor Documentation

◆ SegmentationInterpolationController()

mitk::SegmentationInterpolationController::SegmentationInterpolationController ( )
protected

◆ ~SegmentationInterpolationController()

mitk::SegmentationInterpolationController::~SegmentationInterpolationController ( )
overrideprotected

Member Function Documentation

◆ Activate2DInterpolation()

void mitk::SegmentationInterpolationController::Activate2DInterpolation ( bool  )

Activate/Deactivate the 2D interpolation.

◆ BlockModified()

void mitk::SegmentationInterpolationController::BlockModified ( bool  )

Block reaction to an images Modified() events.

Blocking the scan of the whole image is especially useful when you are about to change a single slice of the image. Then you would send a difference image of this single slice to SegmentationInterpolationController but call image->Modified() anyway. Before calling image->Modified() you should block SegmentationInterpolationController's reactions to this modified by using this method.

◆ Clone()

Pointer mitk::SegmentationInterpolationController::Clone ( ) const

◆ DisableSliceImageCache()

void mitk::SegmentationInterpolationController::DisableSliceImageCache ( )

Disable slice extraction cache for upper and lower slices.

◆ EnableSliceImageCache()

void mitk::SegmentationInterpolationController::EnableSliceImageCache ( )

Enable slice extraction cache for upper and lower slices.

◆ ExtractSlice()

mitk::Image::Pointer mitk::SegmentationInterpolationController::ExtractSlice ( const PlaneGeometry planeGeometry,
unsigned int  sliceIndex,
unsigned int  timeStep,
bool  cache = false 
)
protected

Extract a slice and optionally use a caching mechanism if enabled.

◆ GetInstance()

static SegmentationInterpolationController* mitk::SegmentationInterpolationController::GetInstance ( )
static

Get existing instance or create a new one.

◆ Interpolate()

Image::Pointer mitk::SegmentationInterpolationController::Interpolate ( unsigned int  sliceDimension,
unsigned int  sliceIndex,
const mitk::PlaneGeometry currentPlane,
unsigned int  timeStep,
mitk::ShapeBasedInterpolationAlgorithm::Pointer  algorithm = nullptr 
)

Generates an interpolated image for the given slice.

Parameters
sliceDimensionNumber of the dimension which is constant for all pixels of the meant slice.
sliceIndexWhich slice to take, in the direction specified by sliceDimension. Count starts from 0.
currentPlane
timeStepWhich time step to use
algorithmOptional algorithm instance to potentially benefit from caching for repeated interpolation

◆ InterpolatorForImage()

static SegmentationInterpolationController* mitk::SegmentationInterpolationController::InterpolatorForImage ( const Image )
static

Find interpolator for a given image.

Returns
nullptr if there is no interpolator yet.

This method is useful if several "clients" modify the same image and want to access the interpolations. Then they can share the same object.

◆ mitkClassMacroItkParent()

mitk::SegmentationInterpolationController::mitkClassMacroItkParent ( SegmentationInterpolationController  ,
itk::Object   
)

◆ New()

static Pointer mitk::SegmentationInterpolationController::New ( )
static

◆ OnImageModified()

void mitk::SegmentationInterpolationController::OnImageModified ( const itk::EventObject &  )

◆ PrintStatus()

void mitk::SegmentationInterpolationController::PrintStatus ( )
protected

◆ ScanChangedSlice()

template<typename DATATYPE >
void mitk::SegmentationInterpolationController::ScanChangedSlice ( const itk::Image< DATATYPE, 2 > *  ,
const SetChangedSliceOptions options 
)
protected

internal scan of a single slice

◆ ScanChangedVolume()

template<typename TPixel , unsigned int VImageDimension>
void mitk::SegmentationInterpolationController::ScanChangedVolume ( const itk::Image< TPixel, VImageDimension > *  ,
unsigned int  timeStep 
)
protected

◆ ScanWholeVolume()

template<typename DATATYPE >
void mitk::SegmentationInterpolationController::ScanWholeVolume ( const itk::Image< DATATYPE, 3 > *  ,
const Image volume,
unsigned int  timeStep 
)
protected

◆ SetChangedSlice()

void mitk::SegmentationInterpolationController::SetChangedSlice ( const Image sliceDiff,
unsigned int  sliceDimension,
unsigned int  sliceIndex,
unsigned int  timeStep 
)

Update after changing a single slice.

Parameters
sliceDiffis a 2D image with the difference image of the slice determined by sliceDimension and sliceIndex. The difference is (pixel value in the new slice minus pixel value in the old slice).
sliceDimensionNumber of the dimension which is constant for all pixels of the meant slice.
sliceIndexWhich slice to take, in the direction specified by sliceDimension. Count starts from 0.
timeStepWhich time step is changed

◆ SetChangedVolume()

void mitk::SegmentationInterpolationController::SetChangedVolume ( const Image sliceDiff,
unsigned int  timeStep 
)

◆ SetReferenceVolume()

void mitk::SegmentationInterpolationController::SetReferenceVolume ( const Image segmentation)

Set a reference image (original patient image) - optional.

If this volume is set (must exactly match the dimensions of the segmentation), the interpolation algorithm may consider image content to improve the interpolated (estimated) segmentation.

◆ SetSegmentationVolume()

void mitk::SegmentationInterpolationController::SetSegmentationVolume ( const Image segmentation)

Initialize with a whole volume.

Will scan the volume for segmentation pixels (values other than 0) and fill some internal data structures. You don't have to call this method every time something changes, but only when several slices at once change.

When you change a single slice, call SetChangedSlice() instead.

Member Data Documentation

◆ m_2DInterpolationActivated

bool mitk::SegmentationInterpolationController::m_2DInterpolationActivated
protected

Definition at line 234 of file mitkSegmentationInterpolationController.h.

◆ m_BlockModified

bool mitk::SegmentationInterpolationController::m_BlockModified
protected

Definition at line 233 of file mitkSegmentationInterpolationController.h.

◆ m_EnableSliceImageCache

bool mitk::SegmentationInterpolationController::m_EnableSliceImageCache
protected

Definition at line 236 of file mitkSegmentationInterpolationController.h.

◆ m_ReferenceImage

Image::ConstPointer mitk::SegmentationInterpolationController::m_ReferenceImage
protected

Definition at line 232 of file mitkSegmentationInterpolationController.h.

◆ m_Segmentation

Image::ConstPointer mitk::SegmentationInterpolationController::m_Segmentation
protected

Definition at line 230 of file mitkSegmentationInterpolationController.h.

◆ m_SegmentationCountInSlice

TimeResolvedDirtyVectorType mitk::SegmentationInterpolationController::m_SegmentationCountInSlice
protected

An array of flags. One for each dimension of the image. A flag is set, when a slice in a certain dimension has at least one pixel that is not 0 (which would mean that it has to be considered by the interpolation algorithm).

E.g. flags for axial slices are stored in m_SegmentationCountInSlice[0][index].

Enhanced with time steps it is now m_SegmentationCountInSlice[timeStep][0][index]

Definition at line 226 of file mitkSegmentationInterpolationController.h.

◆ m_SegmentationModifiedObserverTag

std::pair<unsigned long, bool> mitk::SegmentationInterpolationController::m_SegmentationModifiedObserverTag
protected

Definition at line 231 of file mitkSegmentationInterpolationController.h.

◆ m_SliceImageCache

std::map<std::pair<unsigned int, unsigned int>, Image::Pointer> mitk::SegmentationInterpolationController::m_SliceImageCache
protected

Definition at line 237 of file mitkSegmentationInterpolationController.h.

◆ m_SliceImageCacheMutex

std::mutex mitk::SegmentationInterpolationController::m_SliceImageCacheMutex
protected

Definition at line 238 of file mitkSegmentationInterpolationController.h.

◆ s_InterpolatorForImage

InterpolatorMapType mitk::SegmentationInterpolationController::s_InterpolatorForImage
staticprotected

Definition at line 228 of file mitkSegmentationInterpolationController.h.


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