Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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 
79  static SegmentationInterpolationController *InterpolatorForImage(const Image *);
80 
89  void BlockModified(bool);
90 
100  void SetSegmentationVolume(const Image *segmentation);
101 
109  void SetReferenceVolume(const Image *segmentation);
110 
123  void SetChangedSlice(const Image *sliceDiff,
124  unsigned int sliceDimension,
125  unsigned int sliceIndex,
126  unsigned int timeStep);
127  void SetChangedVolume(const Image *sliceDiff, unsigned int timeStep);
128 
142  Image::Pointer Interpolate(unsigned int sliceDimension,
143  unsigned int sliceIndex,
144  const mitk::PlaneGeometry *currentPlane,
145  unsigned int timeStep,
146  mitk::ShapeBasedInterpolationAlgorithm::Pointer algorithm = nullptr);
147 
148  void OnImageModified(const itk::EventObject &);
149 
153  void Activate2DInterpolation(bool);
154 
158  void EnableSliceImageCache();
159 
163  void DisableSliceImageCache();
164 
168  static SegmentationInterpolationController *GetInstance();
169 
170  protected:
175  {
176  public:
178  unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
179  : sliceDimension(sd), sliceIndex(si), dim0(d0), dim1(d1), timeStep(t), pixelData(pixels)
180  {
181  }
182 
183  unsigned int sliceDimension;
184  unsigned int sliceIndex;
185  unsigned int dim0;
186  unsigned int dim1;
187  unsigned int timeStep;
188  const void *pixelData;
189  };
190 
191  typedef std::vector<unsigned int> DirtyVectorType;
192  // typedef std::vector< DirtyVectorType[3] > TimeResolvedDirtyVectorType; // cannot work with C++, so next line is
193  // used for implementation
194  typedef std::vector<std::vector<DirtyVectorType>> TimeResolvedDirtyVectorType;
195  typedef std::map<const Image *, SegmentationInterpolationController *> InterpolatorMapType;
196 
197  SegmentationInterpolationController(); // purposely hidden
199 
201  template <typename DATATYPE>
202  void ScanChangedSlice(const itk::Image<DATATYPE, 2> *, const SetChangedSliceOptions &options);
203 
204  template <typename TPixel, unsigned int VImageDimension>
205  void ScanChangedVolume(const itk::Image<TPixel, VImageDimension> *, unsigned int timeStep);
206 
207  template <typename DATATYPE>
208  void ScanWholeVolume(const itk::Image<DATATYPE, 3> *, const Image *volume, unsigned int timeStep);
209 
210  void PrintStatus();
211 
215  mitk::Image::Pointer ExtractSlice(const PlaneGeometry* planeGeometry, unsigned int sliceIndex, unsigned int timeStep, bool cache = false);
216 
227 
229 
231  std::pair<unsigned long, bool> m_SegmentationModifiedObserverTag; // first: actual tag, second: tag assigned / valid?
235 
237  std::map<std::pair<unsigned int, unsigned int>, Image::Pointer> m_SliceImageCache;
239  };
240 
241 } // namespace
242 
243 #endif
mitk::SegmentationInterpolationController::m_BlockModified
bool m_BlockModified
Definition: mitkSegmentationInterpolationController.h:233
mitk::SegmentationInterpolationController::SetChangedSliceOptions::dim0
unsigned int dim0
Definition: mitkSegmentationInterpolationController.h:185
mitk::SegmentationInterpolationController::m_Segmentation
Image::ConstPointer m_Segmentation
Definition: mitkSegmentationInterpolationController.h:230
mitk::SegmentationInterpolationController::SetChangedSliceOptions::sliceDimension
unsigned int sliceDimension
Definition: mitkSegmentationInterpolationController.h:183
mitk::SegmentationInterpolationController::m_SliceImageCache
std::map< std::pair< unsigned int, unsigned int >, Image::Pointer > m_SliceImageCache
Definition: mitkSegmentationInterpolationController.h:237
mitkImage.h
mitk::SegmentationInterpolationController::m_ReferenceImage
Image::ConstPointer m_ReferenceImage
Definition: mitkSegmentationInterpolationController.h:232
mitk::SegmentationInterpolationController::m_EnableSliceImageCache
bool m_EnableSliceImageCache
Definition: mitkSegmentationInterpolationController.h:236
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::SegmentationInterpolationController::s_InterpolatorForImage
static InterpolatorMapType s_InterpolatorForImage
Definition: mitkSegmentationInterpolationController.h:228
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
mitk::SegmentationInterpolationController::SetChangedSliceOptions
Protected class of mitk::SegmentationInterpolationController. Don't use (you shouldn't be able to do ...
Definition: mitkSegmentationInterpolationController.h:174
mitk::SegmentationInterpolationController::m_SegmentationModifiedObserverTag
std::pair< unsigned long, bool > m_SegmentationModifiedObserverTag
Definition: mitkSegmentationInterpolationController.h:231
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::SegmentationInterpolationController::InterpolatorMapType
std::map< const Image *, SegmentationInterpolationController * > InterpolatorMapType
Definition: mitkSegmentationInterpolationController.h:195
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::SegmentationInterpolationController::SetChangedSliceOptions::timeStep
unsigned int timeStep
Definition: mitkSegmentationInterpolationController.h:187
mitk::SegmentationInterpolationController::m_SegmentationCountInSlice
TimeResolvedDirtyVectorType m_SegmentationCountInSlice
Definition: mitkSegmentationInterpolationController.h:226
mitk::SegmentationInterpolationController::SetChangedSliceOptions::pixelData
const void * pixelData
Definition: mitkSegmentationInterpolationController.h:188
mitk::SegmentationInterpolationController::m_SliceImageCacheMutex
std::mutex m_SliceImageCacheMutex
Definition: mitkSegmentationInterpolationController.h:238
mitkCommon.h
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
mitk::SegmentationInterpolationController::DirtyVectorType
std::vector< unsigned int > DirtyVectorType
Definition: mitkSegmentationInterpolationController.h:191
mitk::SegmentationInterpolationController::SetChangedSliceOptions::dim1
unsigned int dim1
Definition: mitkSegmentationInterpolationController.h:186
mitk::SegmentationInterpolationController::SetChangedSliceOptions::SetChangedSliceOptions
SetChangedSliceOptions(unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
Definition: mitkSegmentationInterpolationController.h:177
mitk::SegmentationInterpolationController::m_2DInterpolationActivated
bool m_2DInterpolationActivated
Definition: mitkSegmentationInterpolationController.h:234
mitk::SegmentationInterpolationController::SetChangedSliceOptions::sliceIndex
unsigned int sliceIndex
Definition: mitkSegmentationInterpolationController.h:184
itk::Image
class ITK_EXPORT Image
Definition: mitkGeometryClipImageFilter.h:25
MitkSegmentationExports.h
mitk::SegmentationInterpolationController
Generates interpolations of 2D slices.
Definition: mitkSegmentationInterpolationController.h:65
mitk::SegmentationInterpolationController::TimeResolvedDirtyVectorType
std::vector< std::vector< DirtyVectorType > > TimeResolvedDirtyVectorType
Definition: mitkSegmentationInterpolationController.h:194
mitkShapeBasedInterpolationAlgorithm.h