Seg3D  2.4
Seg3D is a free volume segmentation and processing tool developed by the NIH Center for Integrative Biomedical Computing at the University of Utah Scientific Computing and Imaging (SCI) Institute.
itkStatisticsImageFilterWithMask.h
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2016 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 // File : itkStatisticsImageFilterWithMask.h
30 // Author : Pavel A. Koshevoy
31 // Created : 2006/06/15 17:09
32 // Copyright : (C) 2004-2008 University of Utah
33 // Description : An enhanced version of the itk::StatisticsImageFilter
34 // adding support for a mask image.
35 
36 #ifndef __itkStatisticsImageFilterWithMask_h
37 #define __itkStatisticsImageFilterWithMask_h
38 
39 // ITK includes:
40 #include <itkImageToImageFilter.h>
41 #include <itkNumericTraits.h>
42 #include <itkArray.h>
43 #include <itkSimpleDataObjectDecorator.h>
44 #include <itkSpatialObject.h>
45 
46 
47 namespace itk {
48 
64 template<class TInputImage>
65 class ITK_EXPORT StatisticsImageFilterWithMask :
66  public ImageToImageFilter<TInputImage, TInputImage>
67 {
68 public:
71  typedef ImageToImageFilter<TInputImage,TInputImage> Superclass;
72  typedef SmartPointer<Self> Pointer;
73  typedef SmartPointer<const Self> ConstPointer;
74 
76  itkNewMacro(Self);
77 
79  itkTypeMacro(StatisticsImageFilterWithMask, ImageToImageFilter);
80 
82  typedef typename TInputImage::Pointer InputImagePointer;
83 
84  typedef typename TInputImage::RegionType RegionType ;
85  typedef typename TInputImage::SizeType SizeType ;
86  typedef typename TInputImage::IndexType IndexType ;
87  typedef typename TInputImage::PixelType PixelType ;
88  typedef typename TInputImage::PointType PointType ;
89 
91  itkStaticConstMacro(ImageDimension, unsigned int,
92  TInputImage::ImageDimension ) ;
93 
95  typedef typename NumericTraits<PixelType>::RealType RealType;
96 
98  typedef typename DataObject::Pointer DataObjectPointer;
99 
101  typedef SimpleDataObjectDecorator<RealType> RealObjectType;
102  typedef SimpleDataObjectDecorator<PixelType> PixelObjectType;
103 
106  typedef SpatialObject<TInputImage::ImageDimension> ImageMaskType;
107  typedef typename ImageMaskType::Pointer ImageMaskPointer;
108 
110  itkSetObjectMacro( ImageMask, ImageMaskType );
111  itkGetConstObjectMacro( ImageMask, ImageMaskType );
112 
114  PixelType GetMinimum() const
115  { return this->GetMinimumOutput()->Get(); }
116  PixelObjectType* GetMinimumOutput();
117  const PixelObjectType* GetMinimumOutput() const;
118 
120  PixelType GetMaximum() const
121  { return this->GetMaximumOutput()->Get(); }
122  PixelObjectType* GetMaximumOutput();
123  const PixelObjectType* GetMaximumOutput() const;
124 
126  RealType GetMean() const
127  { return this->GetMeanOutput()->Get(); }
128  RealObjectType* GetMeanOutput();
129  const RealObjectType* GetMeanOutput() const;
130 
132  RealType GetSigma() const
133  { return this->GetSigmaOutput()->Get(); }
134  RealObjectType* GetSigmaOutput();
135  const RealObjectType* GetSigmaOutput() const;
136 
138  RealType GetVariance() const
139  { return this->GetVarianceOutput()->Get(); }
140  RealObjectType* GetVarianceOutput();
141  const RealObjectType* GetVarianceOutput() const;
142 
144  RealType GetSum() const
145  { return this->GetSumOutput()->Get(); }
146  RealObjectType* GetSumOutput();
147  const RealObjectType* GetSumOutput() const;
148 
151  virtual DataObjectPointer MakeOutput(unsigned int idx);
152 
153 protected:
156  void PrintSelf(std::ostream& os, Indent indent) const;
157 
159  void AllocateOutputs();
160 
162  void BeforeThreadedGenerateData ();
163 
165  void AfterThreadedGenerateData ();
166 
168  void ThreadedGenerateData (const RegionType& outputRegionForThread,
169  ThreadIdType threadId);
170 
171  // Override since the filter needs all the data for the algorithm
172  void GenerateInputRequestedRegion();
173 
174  // Override since the filter produces all of its output
175  void EnlargeOutputRequestedRegion(DataObject *data);
176 
177 private:
178  StatisticsImageFilterWithMask(const Self&); //purposely not implemented
179  void operator=(const Self&); //purposely not implemented
180 
181  mutable ImageMaskPointer m_ImageMask;
182 
183  Array<RealType> m_ThreadSum;
184  Array<RealType> m_SumOfSquares;
185  Array<long> m_Count;
186  Array<PixelType> m_ThreadMin;
187  Array<PixelType> m_ThreadMax;
188 
189 } ; // end of class
190 
191 } // end namespace itk
192 
193 #ifndef ITK_MANUAL_INSTANTIATION
194 #include "itkStatisticsImageFilterWithMask.txx"
195 #endif
196 
197 #endif
Compute min. max, variance and mean of an Image.
Definition: itkStatisticsImageFilterWithMask.h:65
RealType GetVariance() const
Definition: itkStatisticsImageFilterWithMask.h:138
PixelType GetMaximum() const
Definition: itkStatisticsImageFilterWithMask.h:120
DataObject::Pointer DataObjectPointer
Definition: itkStatisticsImageFilterWithMask.h:98
SimpleDataObjectDecorator< RealType > RealObjectType
Definition: itkStatisticsImageFilterWithMask.h:101
RealType GetMean() const
Definition: itkStatisticsImageFilterWithMask.h:126
StatisticsImageFilterWithMask Self
Definition: itkStatisticsImageFilterWithMask.h:70
Definition: itkNormalizeImageFilterWithMask.h:48
SpatialObject< TInputImage::ImageDimension > ImageMaskType
Definition: itkStatisticsImageFilterWithMask.h:106
RealType GetSigma() const
Definition: itkStatisticsImageFilterWithMask.h:132
TInputImage::Pointer InputImagePointer
Definition: itkStatisticsImageFilterWithMask.h:82
PixelType GetMinimum() const
Definition: itkStatisticsImageFilterWithMask.h:114
RealType GetSum() const
Definition: itkStatisticsImageFilterWithMask.h:144
NumericTraits< PixelType >::RealType RealType
Definition: itkStatisticsImageFilterWithMask.h:95