18 #ifndef itkLabelStatisticsImageFilter_h
19 #define itkLabelStatisticsImageFilter_h
24 #include "itksys/hash_map.hxx"
59 template<
typename TInputImage,
typename TLabelImage >
79 typedef typename TInputImage::SizeType
SizeType;
92 itkStaticConstMacro(ImageDimension,
unsigned int,
93 TInputImage::ImageDimension);
136 const unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
137 m_BoundingBox.resize(imageDimension * 2);
138 for (
unsigned int i = 0; i < imageDimension * 2; i += 2 )
143 m_Histogram = ITK_NULLPTR;
163 const unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
164 m_BoundingBox.resize(imageDimension * 2);
165 for (
unsigned int i = 0; i < imageDimension * 2; i += 2 )
172 m_Histogram = HistogramType::New();
179 m_Histogram->SetMeasurementVectorSize(1);
183 m_Histogram->Initialize(hsize, lb, ub);
233 typedef itksys::hash_map< LabelPixelType, LabelStatistics >
MapType;
234 typedef typename itksys::hash_map< LabelPixelType, LabelStatistics >::iterator
MapIterator;
235 typedef typename itksys::hash_map< LabelPixelType, LabelStatistics >::const_iterator
MapConstIterator;
242 itkSetMacro(UseHistograms,
bool);
243 itkGetConstMacro(UseHistograms,
bool);
244 itkBooleanMacro(UseHistograms);
249 return m_ValidLabelValues;
256 this->SetNthInput( 1, const_cast< TLabelImage * >( input ) );
269 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
275 return static_cast<MapSizeType>( m_LabelStatistics.size() );
280 return static_cast<MapSizeType>( this->GetNumberOfObjects() );
284 RealType GetMinimum(LabelPixelType label)
const;
287 RealType GetMaximum(LabelPixelType label)
const;
290 RealType GetMean(LabelPixelType label)
const;
294 RealType GetMedian(LabelPixelType label)
const;
297 RealType GetSigma(LabelPixelType label)
const;
300 RealType GetVariance(LabelPixelType label)
const;
303 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
306 RegionType GetRegion(LabelPixelType label)
const;
309 RealType GetSum(LabelPixelType label)
const;
312 MapSizeType GetCount(LabelPixelType label)
const;
315 HistogramPointer GetHistogram(LabelPixelType label)
const;
318 void SetHistogramParameters(
const int numBins, RealType lowerBound,
319 RealType upperBound);
321 #ifdef ITK_USE_CONCEPT_CHECKING
331 void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
335 void AllocateOutputs() ITK_OVERRIDE;
338 void BeforeThreadedGenerateData() ITK_OVERRIDE;
342 void AfterThreadedGenerateData() ITK_OVERRIDE;
345 void ThreadedGenerateData(const RegionType &
346 outputRegionForThread,
350 void EnlargeOutputRequestedRegion(
DataObject *data) ITK_OVERRIDE;
355 std::vector<
MapType > m_LabelStatisticsPerThread;
359 bool m_UseHistograms;
369 #ifndef ITK_MANUAL_INSTANTIATION
370 #include "itkLabelStatisticsImageFilter.hxx"
Critical section locking class that can be allocated on the stack.
itksys::hash_map< LabelPixelType, LabelStatistics >::iterator MapIterator
bool HasLabel(LabelPixelType label) const
void SetLabelInput(const TLabelImage *input)
Light weight base class for most itk classes.
itksys::hash_map< LabelPixelType, LabelStatistics > MapType
MapSizeType GetNumberOfObjects() const
MapSizeType GetNumberOfLabels() const
virtual const ValidLabelValuesContainerType & GetValidLabelValues() const
std::vector< IndexValueType > BoundingBoxType
TLabelImage::Pointer LabelImagePointer
NumericTraits< PixelType >::RealType RealType
SmartPointer< Self > Pointer
SimpleDataObjectDecorator< RealType > RealObjectType
TInputImage::SizeType SizeType
TLabelImage::SizeType LabelSizeType
This class stores measurement vectors in the context of n-dimensional histogram.
Given an intensity image and a label map, compute min, max, variance and mean of the pixels associate...
HistogramType::Pointer HistogramPointer
DataObject::Pointer DataObjectPointer
static ITK_CONSTEXPR_FUNC T max(const T &)
SizeValueType IdentifierType
Statistics stored per label.
TLabelImage::PixelType LabelPixelType
void SetSize(SizeValueType sz)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API...
TLabelImage::RegionType LabelRegionType
Superclass::MeasurementVectorType MeasurementVectorType
itk::Statistics::Histogram< RealType > HistogramType
~LabelStatisticsImageFilter()
TInputImage::IndexType IndexType
LabelStatistics(const LabelStatistics &l)
BoundingBoxType m_BoundingBox
std::vector< LabelPixelType > ValidLabelValuesContainerType
unsigned int ThreadIdType
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itksys::hash_map< LabelPixelType, LabelStatistics >::const_iterator MapConstIterator
TInputImage::PixelType PixelType
TInputImage::Pointer InputImagePointer
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
SmartPointer< const Self > ConstPointer
TInputImage::RegionType RegionType
Base class for filters that take an image as input and produce an image as output.
LabelStatistics(int size, RealType lowerBound, RealType upperBound)
Control indentation during Print() invocation.
const LabelImageType * GetLabelInput() const
LabelStatisticsImageFilter Self
Define additional traits for native types such as int or float.
TLabelImage LabelImageType
#define itkConceptMacro(name, concept)
HistogramType::Pointer m_Histogram
IdentifierType MapSizeType
Base class for all data objects in ITK.
ImageToImageFilter< TInputImage, TInputImage > Superclass
TLabelImage::IndexType LabelIndexType