Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkSegmentationInterpolationController.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 mitkSegmentationInterpolationController_h
14 #define mitkSegmentationInterpolationController_h
15 
16 #include <mitkCommon.h>
17 #include <mitkImage.h>
20 
21 #include <itkImage.h>
22 #include <itkObjectFactory.h>
23 
24 #include <map>
25 #include <mutex>
26 #include <utility>
27 #include <vector>
28 
29 namespace mitk
30 {
31  class Image;
32 
60  {
61  public:
63  itkFactorylessNewMacro(Self);
64  itkCloneMacro(Self);
65 
74 
83  void BlockModified(bool);
84 
94  void SetSegmentationVolume(const Image *segmentation);
95 
108  void SetChangedSlice(const Image *sliceDiff,
109  unsigned int sliceDimension,
110  unsigned int sliceIndex,
111  unsigned int timeStep);
116  void SetChangedVolume(const Image *sliceDiff, unsigned int timeStep);
117 
131  Image::Pointer Interpolate(unsigned int sliceDimension,
132  unsigned int sliceIndex,
133  const mitk::PlaneGeometry *currentPlane,
134  unsigned int timeStep,
135  mitk::ShapeBasedInterpolationAlgorithm::Pointer algorithm = nullptr);
136 
140  void OnImageModified(const itk::EventObject &);
141 
146 
151 
156 
161 
162  protected:
167  {
168  public:
170  unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
171  : sliceDimension(sd), sliceIndex(si), dim0(d0), dim1(d1), timeStep(t), pixelData(pixels)
172  {
173  }
174 
175  unsigned int sliceDimension;
176  unsigned int sliceIndex;
177  unsigned int dim0;
178  unsigned int dim1;
179  unsigned int timeStep;
180  const void *pixelData;
181  };
182 
183  typedef std::vector<unsigned int> DirtyVectorType;
184  // typedef std::vector< DirtyVectorType[3] > TimeResolvedDirtyVectorType; // cannot work with C++, so next line is
185  // used for implementation
186  typedef std::vector<std::vector<DirtyVectorType>> TimeResolvedDirtyVectorType;
187  typedef std::map<const Image *, SegmentationInterpolationController *> InterpolatorMapType;
188 
189  SegmentationInterpolationController(); // purposely hidden
191 
193  template <typename DATATYPE>
194  void ScanChangedSlice(const itk::Image<DATATYPE, 2> *, const SetChangedSliceOptions &options);
195 
196  template <typename TPixel, unsigned int VImageDimension>
197  void ScanChangedVolume(const itk::Image<TPixel, VImageDimension> *, unsigned int timeStep);
198 
199  template <typename DATATYPE>
200  void ScanWholeVolume(const itk::Image<DATATYPE, 3> *, const Image *volume, unsigned int timeStep);
201 
202  void PrintStatus();
203 
207  mitk::Image::Pointer ExtractSlice(const PlaneGeometry* planeGeometry, unsigned int sliceIndex, unsigned int timeStep, bool cache = false);
208 
219 
221 
222  Image::ConstPointer m_Segmentation;
223  std::pair<unsigned long, bool> m_SegmentationModifiedObserverTag; // first: actual tag, second: tag assigned / valid?
226 
228  std::map<std::pair<unsigned int, unsigned int>, Image::Pointer> m_SliceImageCache;
230  };
231 
232 } // namespace
233 
234 #endif
#define MITKSEGMENTATION_EXPORT
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Describes the geometry of a plane object.
Protected class of mitk::SegmentationInterpolationController. Don't use (you shouldn't be able to do ...
SetChangedSliceOptions(unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
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.
void BlockModified(bool)
Block reaction to an images Modified() events.
void OnImageModified(const itk::EventObject &)
Callback invoked when the observed segmentation image is modified. Triggers a full rescan of the segm...
mitkClassMacroItkParent(SegmentationInterpolationController, itk::Object)
std::map< const Image *, SegmentationInterpolationController * > InterpolatorMapType
void SetChangedSlice(const Image *sliceDiff, unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep)
Update after changing a single slice.
void SetChangedVolume(const Image *sliceDiff, unsigned int timeStep)
Update after changing an entire volume at a given time step.
void ScanChangedSlice(const itk::Image< DATATYPE, 2 > *, const SetChangedSliceOptions &options)
internal scan of a single slice
std::map< std::pair< unsigned int, unsigned int >, Image::Pointer > m_SliceImageCache
void ScanWholeVolume(const itk::Image< DATATYPE, 3 > *, const Image *volume, unsigned int timeStep)
std::vector< std::vector< DirtyVectorType > > TimeResolvedDirtyVectorType
void ScanChangedVolume(const itk::Image< TPixel, VImageDimension > *, unsigned int timeStep)
mitk::Image::Pointer ExtractSlice(const PlaneGeometry *planeGeometry, unsigned int sliceIndex, unsigned int timeStep, bool cache=false)
static SegmentationInterpolationController * InterpolatorForImage(const Image *)
Find interpolator for a given image.
static SegmentationInterpolationController * GetInstance()
Get existing instance or create a new one.
void SetSegmentationVolume(const Image *segmentation)
Initialize with a whole volume.
class ITK_EXPORT Image
Find image slices visible on a given plane.