Medical Imaging Interaction Toolkit  2021.10.99-1c4db16f
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_Included
14 #define mitkSegmentationInterpolationController_h_Included
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 
226  TimeResolvedDirtyVectorType m_SegmentationCountInSlice;
227 
228  static InterpolatorMapType s_InterpolatorForImage;
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
#define MITKSEGMENTATION_EXPORT
std::map< std::pair< unsigned int, unsigned int >, Image::Pointer > m_SliceImageCache
DataCollection - Class to facilitate loading/accessing structured data.
SetChangedSliceOptions(unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels)
class ITK_EXPORT Image
Protected class of mitk::SegmentationInterpolationController. Don&#39;t use (you shouldn&#39;t be able to do ...
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
Image class for storing images.
Definition: mitkImage.h:69
std::map< const Image *, SegmentationInterpolationController * > InterpolatorMapType
std::vector< std::vector< DirtyVectorType > > TimeResolvedDirtyVectorType
Describes a two-dimensional, rectangular plane.