Medical Imaging Interaction Toolkit  2022.04.99-b878213f
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 MITK_MINMAXIMAGEFILTERWITHINDEX_H
14 #define MITK_MINMAXIMAGEFILTERWITHINDEX_H
15 
17 
18 #include <itkImage.h>
19 #include <itkImageToImageFilter.h>
20 #include <itkImageRegionConstIteratorWithIndex.h>
21 
22 
23 
24 namespace itk
25 {
26 template <typename TInputImage>
27 class MinMaxImageFilterWithIndex: public itk::ImageToImageFilter<TInputImage, TInputImage>
28 {
29 public:
32  typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
35 
37  itkNewMacro(Self);
38 
40  itkTypeMacro(MinMaxImageFilterWithIndex, ImageToImageFilter);
41 
42  typedef typename TInputImage::RegionType RegionType;
43  typedef typename TInputImage::SizeType SizeType;
44  typedef typename TInputImage::IndexType IndexType;
45  typedef typename TInputImage::PixelType PixelType;
46  typedef typename NumericTraits< PixelType >::RealType RealType;
47 
48 
49  RealType GetMin() const
50  {
51  return m_Min;
52  }
53 
54  RealType GetMax() const
55  {
56  return m_Max;
57  }
58 
59  IndexType GetMinIndex() const
60  {
61  return m_MinIndex;
62  }
63 
64  IndexType GetMaxIndex() const
65  {
66  return m_MaxIndex;
67  }
68 
69 protected:
71  {
72  this->DynamicMultiThreadingOff();
73  }
74 
75  void AllocateOutputs() override;
76 
77  void ThreadedGenerateData(const RegionType &
78  outputRegionForThread,
79  ThreadIdType threadId) override;
80 
81  void BeforeThreadedGenerateData() override;
82 
83  void AfterThreadedGenerateData() override;
84 
85 private:
86  std::vector<PixelType> m_ThreadMin;
87  std::vector<PixelType> m_ThreadMax;
88  std::vector<IndexType> m_ThreadMinIndex;
89  std::vector<IndexType> m_ThreadMaxIndex;
90 
91  PixelType m_Min;
92  PixelType m_Max;
93  IndexType m_MinIndex;
94  IndexType m_MaxIndex;
95 };
96 }
97 
98 #include "mitkMinMaxImageFilterWithIndex.hxx"
99 
100 
101 #endif
NumericTraits< PixelType >::RealType RealType
void AfterThreadedGenerateData() override
void BeforeThreadedGenerateData() override
ImageToImageFilter< TInputImage, TInputImage > Superclass
void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType threadId) override