Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkMinMaxImageFilterWithIndex.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 mitkMinMaxImageFilterWithIndex_h
14 #define mitkMinMaxImageFilterWithIndex_h
15 
17 
18 #include <itkImage.h>
19 #include <itkImageToImageFilter.h>
20 #include <itkImageRegionConstIteratorWithIndex.h>
21 
22 
23 
24 namespace itk
25 {
37 template <typename TInputImage>
38 class MinMaxImageFilterWithIndex: public itk::ImageToImageFilter<TInputImage, TInputImage>
39 {
40 public:
43  typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(MinMaxImageFilterWithIndex, ImageToImageFilter);
52 
53  typedef typename TInputImage::RegionType RegionType;
54  typedef typename TInputImage::SizeType SizeType;
55  typedef typename TInputImage::IndexType IndexType;
56  typedef typename TInputImage::PixelType PixelType;
57  typedef typename NumericTraits< PixelType >::RealType RealType;
58 
63  RealType GetMin() const
64  {
65  return m_Min;
66  }
67 
72  RealType GetMax() const
73  {
74  return m_Max;
75  }
76 
82  {
83  return m_MinIndex;
84  }
85 
91  {
92  return m_MaxIndex;
93  }
94 
95 protected:
97  {
98  this->DynamicMultiThreadingOff();
99  }
100 
101  void AllocateOutputs() override;
102 
104  outputRegionForThread,
105  ThreadIdType threadId) override;
106 
107  void BeforeThreadedGenerateData() override;
108 
109  void AfterThreadedGenerateData() override;
110 
111 private:
112  std::vector<PixelType> m_ThreadMin;
113  std::vector<PixelType> m_ThreadMax;
114  std::vector<IndexType> m_ThreadMinIndex;
115  std::vector<IndexType> m_ThreadMaxIndex;
116 
117  PixelType m_Min;
118  PixelType m_Max;
119  IndexType m_MinIndex;
120  IndexType m_MaxIndex;
121 };
122 }
123 
124 #include <mitkMinMaxImageFilterWithIndex.tpp>
125 
126 
127 #endif
Computes the minimum and maximum pixel values and their indices in an image.
IndexType GetMinIndex() const
Get the image index of the minimum pixel value.
void AfterThreadedGenerateData() override
void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType threadId) override
RealType GetMax() const
Get the maximum pixel value found in the image.
ImageToImageFilter< TInputImage, TInputImage > Superclass
RealType GetMin() const
Get the minimum pixel value found in the image.
NumericTraits< PixelType >::RealType RealType
IndexType GetMaxIndex() const
Get the image index of the maximum pixel value.
void BeforeThreadedGenerateData() override