Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
itkMaskedStatisticsImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 #ifndef __itkMaskedStatisticsImageFilter_h
19 #define __itkMaskedStatisticsImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkNumericTraits.h"
23 #include "itkArray.h"
24 #include "itkSimpleDataObjectDecorator.h"
25 
26 namespace itk
27 {
48  template< typename TInputImage , typename TMaskImage = ::itk::Image<unsigned char, TInputImage::ImageDimension> >
50  public ImageToImageFilter< TInputImage, TInputImage >
51  {
52  public:
55  typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
58 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(MaskedStatisticsImageFilter, ImageToImageFilter);
64 
67  typedef typename Superclass::InputImagePointer InputImagePointer;
68 
69  typedef typename TInputImage::RegionType RegionType;
70  typedef typename TInputImage::SizeType SizeType;
71  typedef typename TInputImage::IndexType IndexType;
72  typedef typename TInputImage::PixelType PixelType;
73 
75  itkStaticConstMacro(ImageDimension, unsigned int,
76  TInputImage::ImageDimension);
77 
79  typedef typename NumericTraits< PixelType >::RealType RealType;
80 
82  typedef typename DataObject::Pointer DataObjectPointer;
83 
85  typedef SimpleDataObjectDecorator< RealType > RealObjectType;
86  typedef SimpleDataObjectDecorator< PixelType > PixelObjectType;
87 
88  typedef TMaskImage MaskImageType;
89  typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
90  typedef typename MaskImageType::RegionType MaskImageRegionType;
91 
94  { return this->GetMinimumOutput()->Get(); }
95  PixelObjectType * GetMinimumOutput();
96 
97  const PixelObjectType * GetMinimumOutput() const;
98 
101  { return this->GetMaximumOutput()->Get(); }
102  PixelObjectType * GetMaximumOutput();
103 
104  const PixelObjectType * GetMaximumOutput() const;
105 
108  { return this->GetMeanOutput()->Get(); }
109  RealObjectType * GetMeanOutput();
110 
111  const RealObjectType * GetMeanOutput() const;
112 
115  { return this->GetSigmaOutput()->Get(); }
116  RealObjectType * GetSigmaOutput();
117 
118  const RealObjectType * GetSigmaOutput() const;
119 
122  { return this->GetVarianceOutput()->Get(); }
123  RealObjectType * GetVarianceOutput();
124 
125  const RealObjectType * GetVarianceOutput() const;
126 
128  RealType GetSum() const
129  { return this->GetSumOutput()->Get(); }
130  RealObjectType * GetSumOutput();
131 
132  const RealObjectType * GetSumOutput() const;
133 
136  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
137  using Superclass::MakeOutput;
139 
140  itkSetConstObjectMacro(Mask, MaskImageType);
141  itkGetConstObjectMacro(Mask, MaskImageType);
142 
143 #ifdef ITK_USE_CONCEPT_CHECKING
144  // Begin concept checking
145  itkConceptMacro( InputHasNumericTraitsCheck,
146  ( Concept::HasNumericTraits< PixelType > ) );
147  // End concept checking
148 #endif
149 
150  protected:
153  void PrintSelf(std::ostream & os, Indent indent) const override;
154 
158  void AllocateOutputs() override;
159 
161  void BeforeThreadedGenerateData() override;
162 
165  void AfterThreadedGenerateData() override;
166 
168  void ThreadedGenerateData(const RegionType &
169  outputRegionForThread,
170  ThreadIdType threadId) override;
171 
172  // Override since the filter needs all the data for the algorithm
173  void GenerateInputRequestedRegion() override;
174 
175  // Override since the filter produces all of its output
176  void EnlargeOutputRequestedRegion(DataObject *data) override;
177 
178  private:
179  MaskedStatisticsImageFilter(const Self &); //purposely not implemented
180  void operator=(const Self &); //purposely not implemented
181 
182  Array< RealType > m_ThreadSum;
183  Array< RealType > m_SumOfSquares;
184  Array< SizeValueType > m_Count;
185  Array< PixelType > m_ThreadMin;
186  Array< PixelType > m_ThreadMax;
187  MaskImageConstPointer m_Mask;
188  }; // end of class
189 } // end namespace itk
190 
191 #ifndef ITK_MANUAL_INSTANTIATION
192 #include "itkMaskedStatisticsImageFilter.hxx"
193 #endif
194 
195 #endif
itk::MaskedStatisticsImageFilter::GetSigma
RealType GetSigma() const
Definition: itkMaskedStatisticsImageFilter.h:114
itk::MaskedStatisticsImageFilter::MakeOutput
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
itk::MaskedStatisticsImageFilter::ThreadedGenerateData
void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType threadId) override
itk::MaskedStatisticsImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: itkMaskedStatisticsImageFilter.h:70
itk::MaskedStatisticsImageFilter::GetSum
RealType GetSum() const
Definition: itkMaskedStatisticsImageFilter.h:128
itk::MaskedStatisticsImageFilter::GetSigmaOutput
RealObjectType * GetSigmaOutput()
itk::MaskedStatisticsImageFilter::InputImagePointer
Superclass::InputImagePointer InputImagePointer
Definition: itkMaskedStatisticsImageFilter.h:67
itk::SmartPointer< Self >
itk::MaskedStatisticsImageFilter::GetMinimum
PixelType GetMinimum() const
Definition: itkMaskedStatisticsImageFilter.h:93
itk::MaskedStatisticsImageFilter::itkStaticConstMacro
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension)
mitk::ImageMappingHelper::InputImageType
::mitk::Image InputImageType
Definition: mitkImageMappingHelper.h:47
itk::MaskedStatisticsImageFilter
Compute min. max, variance and mean of an (masked) Image.
Definition: itkMaskedStatisticsImageFilter.h:49
itk::MaskedStatisticsImageFilter::GenerateInputRequestedRegion
void GenerateInputRequestedRegion() override
itk::MaskedStatisticsImageFilter::GetMaximumOutput
PixelObjectType * GetMaximumOutput()
itk::MaskedStatisticsImageFilter::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkMaskedStatisticsImageFilter.h:57
itk::MaskedStatisticsImageFilter::InputImageType
Superclass::InputImageType InputImageType
Definition: itkMaskedStatisticsImageFilter.h:63
itk::MaskedStatisticsImageFilter::GetMean
RealType GetMean() const
Definition: itkMaskedStatisticsImageFilter.h:107
itk::MaskedStatisticsImageFilter::GetVariance
RealType GetVariance() const
Definition: itkMaskedStatisticsImageFilter.h:121
itk::MaskedStatisticsImageFilter::GetMeanOutput
RealObjectType * GetMeanOutput()
itk::MaskedStatisticsImageFilter::AllocateOutputs
void AllocateOutputs() override
itk::MaskedStatisticsImageFilter::DataObjectPointerArraySizeType
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: itkMaskedStatisticsImageFilter.h:136
itk::MaskedStatisticsImageFilter::MaskImageRegionType
MaskImageType::RegionType MaskImageRegionType
Definition: itkMaskedStatisticsImageFilter.h:90
itk::MaskedStatisticsImageFilter::Self
MaskedStatisticsImageFilter Self
Definition: itkMaskedStatisticsImageFilter.h:54
itk::MaskedStatisticsImageFilter::MaskedStatisticsImageFilter
MaskedStatisticsImageFilter()
itk::MaskedStatisticsImageFilter::RealObjectType
SimpleDataObjectDecorator< RealType > RealObjectType
Definition: itkMaskedStatisticsImageFilter.h:85
itk::MaskedStatisticsImageFilter::AfterThreadedGenerateData
void AfterThreadedGenerateData() override
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
itk::MaskedStatisticsImageFilter::PixelType
TInputImage::PixelType PixelType
Definition: itkMaskedStatisticsImageFilter.h:72
itk::MaskedStatisticsImageFilter::RealType
NumericTraits< PixelType >::RealType RealType
Definition: itkMaskedStatisticsImageFilter.h:79
itk::MaskedStatisticsImageFilter::GetMaximum
PixelType GetMaximum() const
Definition: itkMaskedStatisticsImageFilter.h:100
itk::MaskedStatisticsImageFilter::Superclass
ImageToImageFilter< TInputImage, TInputImage > Superclass
Definition: itkMaskedStatisticsImageFilter.h:55
itk::MaskedStatisticsImageFilter::MaskImageConstPointer
MaskImageType::ConstPointer MaskImageConstPointer
Definition: itkMaskedStatisticsImageFilter.h:89
itk::MaskedStatisticsImageFilter::GetSumOutput
RealObjectType * GetSumOutput()
itk::MaskedStatisticsImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::MaskedStatisticsImageFilter::GetVarianceOutput
RealObjectType * GetVarianceOutput()
itk::MaskedStatisticsImageFilter::GetMinimumOutput
PixelObjectType * GetMinimumOutput()
itk::MaskedStatisticsImageFilter::DataObjectPointer
DataObject::Pointer DataObjectPointer
Definition: itkMaskedStatisticsImageFilter.h:82
itk::MaskedStatisticsImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
itk::MaskedStatisticsImageFilter::PixelObjectType
SimpleDataObjectDecorator< PixelType > PixelObjectType
Definition: itkMaskedStatisticsImageFilter.h:86
itk::MaskedStatisticsImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: itkMaskedStatisticsImageFilter.h:88
itk::MaskedStatisticsImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: itkMaskedStatisticsImageFilter.h:71
itk::MaskedStatisticsImageFilter::~MaskedStatisticsImageFilter
~MaskedStatisticsImageFilter() override
Definition: itkMaskedStatisticsImageFilter.h:152
itk::MaskedStatisticsImageFilter::Pointer
SmartPointer< Self > Pointer
Definition: itkMaskedStatisticsImageFilter.h:56
itk::MaskedStatisticsImageFilter::RegionType
TInputImage::RegionType RegionType
Definition: itkMaskedStatisticsImageFilter.h:69
itk::MaskedStatisticsImageFilter::EnlargeOutputRequestedRegion
void EnlargeOutputRequestedRegion(DataObject *data) override