Medical Imaging Interaction Toolkit  2022.04.99-b878213f
Medical Imaging Interaction Toolkit
mitkHotspotMaskGenerator.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 MITKHOTSPOTCALCULATOR_H
14 #define MITKHOTSPOTCALCULATOR_H
15 
16 #include <itkObject.h>
17 #include <mitkImage.h>
18 #include <itkImage.h>
19 #include <itkTimeStamp.h>
20 #include <stdexcept>
22 #include <mitkImageTimeSelector.h>
23 #include <mitkMaskGenerator.h>
24 
25 
26 namespace mitk
27 {
38  {
39  public:
45 
47  itkNewMacro(Self);
48  itkTypeMacro(HotspotMaskGenerator, MaskGenerator);
49 
53  void SetInputImage(mitk::Image::Pointer inputImage);
54 
58  void SetMask(MaskGenerator::Pointer mask);
59 
63  void SetHotspotRadiusInMM(double radiusInMillimeter);
64 
65  const double& GetHotspotRadiusinMM() const;
66 
70  void SetHotspotMustBeCompletelyInsideImage(bool hotspotCompletelyInsideImage);
71 
72  bool GetHotspotMustBeCompletelyInsideImage() const;
73 
77  void SetLabel(unsigned short label);
78 
82  mitk::Image::ConstPointer GetMask() override;
83 
87  vnl_vector<int> GetHotspotIndex();
88 
92  vnl_vector<int> GetConvolutionImageMinIndex();
93 
98  void SetTimeStep(unsigned int timeStep) override;
99 
100  protected:
102 
103  ~HotspotMaskGenerator() override;
104 
106  {
107  public:
108  bool Defined;
109  double Max;
110  double Min;
111  vnl_vector<int> MaxIndex;
112  vnl_vector<int> MinIndex;
113 
115  :Defined(false)
116  ,Max(itk::NumericTraits<double>::min())
117  ,Min(itk::NumericTraits<double>::max())
118  {
119  }
120  };
121 
122  private:
124  template <unsigned int VImageDimension>
125  itk::Size<VImageDimension>
126  CalculateConvolutionKernelSize(double spacing[VImageDimension], double radiusInMM);
127 
129  template <unsigned int VImageDimension>
131  GenerateHotspotSearchConvolutionKernel(double spacing[VImageDimension], double radiusInMM);
132 
134  template <typename TPixel, unsigned int VImageDimension>
136  GenerateConvolutionImage( const itk::Image<TPixel, VImageDimension>* inputImage );
137 
138 
140  template < typename TPixel, unsigned int VImageDimension>
141  void
142  FillHotspotMaskPixels( itk::Image<TPixel, VImageDimension>* maskImage,
143  itk::Point<double, VImageDimension> sphereCenter,
144  double sphereRadiusInMM);
145 
146 
148  template <typename TPixel, unsigned int VImageDimension>
149  void
150  CalculateHotspotMask(itk::Image<TPixel, VImageDimension>* inputImage,
151  const itk::Image<unsigned short, VImageDimension>* maskImage,
152  unsigned int label);
153 
154 
155  template <typename TPixel, unsigned int VImageDimension >
156  ImageExtrema CalculateExtremaWorld( const itk::Image<TPixel, VImageDimension>* inputImage,
157  const itk::Image<unsigned short, VImageDimension>* maskImage,
158  double neccessaryDistanceToImageBorderInMM,
159  unsigned int label);
160 
161  bool IsUpdateRequired() const;
162 
164  HotspotMaskGenerator & operator=(const HotspotMaskGenerator &);
165 
166  MaskGenerator::Pointer m_Mask;
167  mitk::Image::Pointer m_InternalMask;
168  mitk::Image::Pointer m_internalImage;
169  itk::Image<unsigned short, 2>::ConstPointer m_internalMask2D;
170  itk::Image<unsigned short, 3>::ConstPointer m_internalMask3D;
171  double m_HotspotRadiusinMM;
172  bool m_HotspotMustBeCompletelyInsideImage;
173  unsigned short m_Label;
174  vnl_vector<int> m_ConvolutionImageMinIndex, m_ConvolutionImageMaxIndex;
175  unsigned long m_InternalMaskUpdateTime;
176  };
177 }
178 #endif // MITKHOTSPOTCALCULATOR
179 
180 
itk::SmartPointer< const Self > ConstPointer
Base Class for all Mask Generators. Mask generators are classes that provide functionality for the cr...
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKIMAGESTATISTICS_EXPORT
itk::SmartPointer< Self > Pointer
The HotspotMaskGenerator class is used when a hotspot has to be found in an image. A hotspot is the region of the image where the mean intensity is maximal (=brightest spot). It is usually used in PET scans. The identification of the hotspot is done as follows: First a cubic (or circular, if image is 2d) mask of predefined size is generated. This mask is then convolved with the input image (in fourier domain). The maximum value of the convolved image then corresponds to the hotspot. If a maskGenerator is set, only the pixels of the convolved image where the corresponding mask is == label are searched for the maximum value.