Medical Imaging Interaction Toolkit  2025.12.02
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 
66  {
67  public:
69  itkFactorylessNewMacro(Self);
70  itkCloneMacro(Self);
71 
80 
89  void BlockModified(bool);
90 
100  void SetSegmentationVolume(const Image *segmentation);
101 
114  void SetChangedSlice(const Image *sliceDiff,
115  unsigned int sliceDimension,
116  unsigned int sliceIndex,
117  unsigned int timeStep);
118  void SetChangedVolume(const Image *sliceDiff, unsigned int timeStep);
119 
133  Image::Pointer Interpolate(unsigned int sliceDimension,
134  unsigned int sliceIndex,
135  const mitk::PlaneGeometry *currentPlane,
136  unsigned int timeStep,
137  mitk::ShapeBasedInterpolationAlgorithm::Pointer algorithm = nullptr);
138 
139  void OnImageModified(const itk::EventObject &);
140 
145 
150 
155 
160 
161  protected:
166  {
167  public:
169  unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
170  : sliceDimension(sd), sliceIndex(si), dim0(d0), dim1(d1), timeStep(t), pixelData(pixels)
171  {
172  }
173 
174  unsigned int sliceDimension;
175  unsigned int sliceIndex;
176  unsigned int dim0;
177  unsigned int dim1;
178  unsigned int timeStep;
179  const void *pixelData;
180  };
181 
182  typedef std::vector<unsigned int> DirtyVectorType;
183  // typedef std::vector< DirtyVectorType[3] > TimeResolvedDirtyVectorType; // cannot work with C++, so next line is
184  // used for implementation
185  typedef std::vector<std::vector<DirtyVectorType>> TimeResolvedDirtyVectorType;
186  typedef std::map<const Image *, SegmentationInterpolationController *> InterpolatorMapType;
187 
188  SegmentationInterpolationController(); // purposely hidden
190 
192  template <typename DATATYPE>
193  void ScanChangedSlice(const itk::Image<DATATYPE, 2> *, const SetChangedSliceOptions &options);
194 
195  template <typename TPixel, unsigned int VImageDimension>
196  void ScanChangedVolume(const itk::Image<TPixel, VImageDimension> *, unsigned int timeStep);
197 
198  template <typename DATATYPE>
199  void ScanWholeVolume(const itk::Image<DATATYPE, 3> *, const Image *volume, unsigned int timeStep);
200 
201  void PrintStatus();
202 
206  mitk::Image::Pointer ExtractSlice(const PlaneGeometry* planeGeometry, unsigned int sliceIndex, unsigned int timeStep, bool cache = false);
207 
218 
220 
222  std::pair<unsigned long, bool> m_SegmentationModifiedObserverTag; // first: actual tag, second: tag assigned / valid?
225 
227  std::map<std::pair<unsigned int, unsigned int>, Image::Pointer> m_SliceImageCache;
229  };
230 
231 } // namespace
232 
233 #endif
#define MITKSEGMENTATION_EXPORT
Image class for storing images.
Definition: mitkImage.h:70
Describes a two-dimensional, rectangular plane.
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 &)
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)
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.