Medical Imaging Interaction Toolkit
2018.4.99-389bf124
Medical Imaging Interaction Toolkit
|
Generates interpolations of 2D slices. More...
#include <mitkSegmentationInterpolationController.h>
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) |
Generates an interpolated image for the given slice. More... | |
void | OnImageModified (const itk::EventObject &) |
void | Activate2DInterpolation (bool) |
Static Public Member Functions | |
static Pointer | New () |
static SegmentationInterpolationController * | InterpolatorForImage (const Image *) |
Find interpolator for a given image. More... | |
static SegmentationInterpolationController * | GetInstance () |
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 () |
Static Protected Attributes | |
static InterpolatorMapType | s_InterpolatorForImage |
Generates interpolations of 2D slices.
This class keeps track of the contents of a 3D segmentation image.
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. This is perhaps better to understand from the following picture (where red items just mean to symbolize "there is some segmentation" - in reality there is an integer count).
$Author$
Definition at line 67 of file mitkSegmentationInterpolationController.h.
|
protected |
Definition at line 178 of file mitkSegmentationInterpolationController.h.
|
protected |
Definition at line 182 of file mitkSegmentationInterpolationController.h.
|
protected |
Definition at line 181 of file mitkSegmentationInterpolationController.h.
|
protected |
Definition at line 45 of file mitkSegmentationInterpolationController.cpp.
|
overrideprotected |
Definition at line 66 of file mitkSegmentationInterpolationController.cpp.
References s_InterpolatorForImage.
void mitk::SegmentationInterpolationController::Activate2DInterpolation | ( | bool | status | ) |
Activate/Deactivate the 2D interpolation.
Definition at line 50 of file mitkSegmentationInterpolationController.cpp.
References m_2DInterpolationActivated.
void mitk::SegmentationInterpolationController::BlockModified | ( | bool | block | ) |
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.
Definition at line 87 of file mitkSegmentationInterpolationController.cpp.
References m_BlockModified.
Referenced by mitk::DiffImageApplier::ExecuteOperation(), and mitk::OverwriteSliceImageFilter::GenerateData().
Pointer mitk::SegmentationInterpolationController::Clone | ( | ) | const |
|
static |
Get existing instance or create a new one.
Definition at line 55 of file mitkSegmentationInterpolationController.cpp.
References New().
mitk::Image::Pointer mitk::SegmentationInterpolationController::Interpolate | ( | unsigned int | sliceDimension, |
unsigned int | sliceIndex, | ||
const mitk::PlaneGeometry * | currentPlane, | ||
unsigned int | timeStep | ||
) |
Generates an interpolated image for the given slice.
sliceDimension | Number of the dimension which is constant for all pixels of the meant slice. |
sliceIndex | Which slice to take, in the direction specified by sliceDimension. Count starts from 0. |
timeStep | Which time step to use |
Definition at line 432 of file mitkSegmentationInterpolationController.cpp.
References mitk::PlaneGeometry::Clone(), mitk::BaseGeometry::GetOrigin(), m_ReferenceImage, m_Segmentation, m_SegmentationCountInSlice, MITK_ERROR, mitk::ShapeBasedInterpolationAlgorithm::New(), and mitk::ExtractSliceFilter::New().
|
static |
Find interpolator for a given image.
This method is useful if several "clients" modify the same image and want to access the interpolations. Then they can share the same object.
Definition at line 31 of file mitkSegmentationInterpolationController.cpp.
References s_InterpolatorForImage.
Referenced by mitk::DiffImageApplier::ExecuteOperation(), and mitk::OverwriteSliceImageFilter::GenerateData().
mitk::SegmentationInterpolationController::mitkClassMacroItkParent | ( | SegmentationInterpolationController | , |
itk::Object | |||
) |
|
static |
Referenced by GetInstance().
void mitk::SegmentationInterpolationController::OnImageModified | ( | const itk::EventObject & | ) |
Definition at line 79 of file mitkSegmentationInterpolationController.cpp.
References m_2DInterpolationActivated, m_BlockModified, m_Segmentation, and SetSegmentationVolume().
Referenced by SetSegmentationVolume().
|
protected |
Definition at line 373 of file mitkSegmentationInterpolationController.cpp.
References m_SegmentationCountInSlice, and MITK_INFO.
|
protected |
internal scan of a single slice
Definition at line 244 of file mitkSegmentationInterpolationController.cpp.
References mitk::SegmentationInterpolationController::SetChangedSliceOptions::dim0, mitk::SegmentationInterpolationController::SetChangedSliceOptions::dim1, m_SegmentationCountInSlice, mitk::SegmentationInterpolationController::SetChangedSliceOptions::pixelData, mitk::SegmentationInterpolationController::SetChangedSliceOptions::sliceDimension, mitk::SegmentationInterpolationController::SetChangedSliceOptions::sliceIndex, and mitk::SegmentationInterpolationController::SetChangedSliceOptions::timeStep.
Referenced by SetChangedSlice().
|
protected |
Definition at line 297 of file mitkSegmentationInterpolationController.cpp.
References m_SegmentationCountInSlice.
Referenced by SetChangedVolume().
|
protected |
Definition at line 352 of file mitkSegmentationInterpolationController.cpp.
References mitk::Image::GetDimension(), mitk::Image::GetVolumeData(), and m_SegmentationCountInSlice.
Referenced by SetSegmentationVolume().
void mitk::SegmentationInterpolationController::SetChangedSlice | ( | const Image * | sliceDiff, |
unsigned int | sliceDimension, | ||
unsigned int | sliceIndex, | ||
unsigned int | timeStep | ||
) |
Update after changing a single slice.
sliceDiff | is 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). |
sliceDimension | Number of the dimension which is constant for all pixels of the meant slice. |
sliceIndex | Which slice to take, in the direction specified by sliceDimension. Count starts from 0. |
timeStep | Which time step is changed |
Definition at line 197 of file mitkSegmentationInterpolationController.cpp.
References AccessFixedDimensionByItk_1, mitk::ImageAccessorBase::GetData(), m_SegmentationCountInSlice, and ScanChangedSlice().
Referenced by mitk::DiffImageApplier::ExecuteOperation(), and mitk::OverwriteSliceImageFilter::GenerateData().
void mitk::SegmentationInterpolationController::SetChangedVolume | ( | const Image * | sliceDiff, |
unsigned int | timeStep | ||
) |
Definition at line 184 of file mitkSegmentationInterpolationController.cpp.
References AccessFixedDimensionByItk_1, mitk::Image::GetDimension(), and ScanChangedVolume().
Referenced by mitk::DiffImageApplier::ExecuteOperation().
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.
Definition at line 155 of file mitkSegmentationInterpolationController.cpp.
References m_ReferenceImage, m_Segmentation, and MITK_WARN.
Referenced by 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.
Definition at line 92 of file mitkSegmentationInterpolationController.cpp.
References AccessFixedDimensionByItk_2, mitk::Image::GetDimension(), m_ReferenceImage, m_Segmentation, m_SegmentationCountInSlice, mitk::ImageTimeSelector::New(), OnImageModified(), s_InterpolatorForImage, ScanWholeVolume(), and SetReferenceVolume().
Referenced by OnImageModified().
|
protected |
Definition at line 215 of file mitkSegmentationInterpolationController.h.
Referenced by Activate2DInterpolation(), and OnImageModified().
|
protected |
Definition at line 214 of file mitkSegmentationInterpolationController.h.
Referenced by BlockModified(), and OnImageModified().
|
protected |
Definition at line 213 of file mitkSegmentationInterpolationController.h.
Referenced by Interpolate(), SetReferenceVolume(), and SetSegmentationVolume().
|
protected |
Definition at line 212 of file mitkSegmentationInterpolationController.h.
Referenced by Interpolate(), OnImageModified(), SetReferenceVolume(), and SetSegmentationVolume().
|
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 208 of file mitkSegmentationInterpolationController.h.
Referenced by Interpolate(), PrintStatus(), ScanChangedSlice(), ScanChangedVolume(), ScanWholeVolume(), SetChangedSlice(), and SetSegmentationVolume().
|
staticprotected |
Definition at line 210 of file mitkSegmentationInterpolationController.h.
Referenced by InterpolatorForImage(), SetSegmentationVolume(), and ~SegmentationInterpolationController().