18#ifndef itkLabelStatisticsImageFilter_h
19#define itkLabelStatisticsImageFilter_h
27#include <unordered_map>
62template <
typename TInputImage,
typename TLabelImage>
96 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
138 const unsigned int imageDimension = Self::ImageDimension;
139 m_BoundingBox.resize(imageDimension * 2);
140 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
145 m_Histogram =
nullptr;
165 const unsigned int imageDimension = Self::ImageDimension;
166 m_BoundingBox.resize(imageDimension * 2);
167 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
181 m_Histogram->SetMeasurementVectorSize(1);
185 m_Histogram->Initialize(hsize, lb, ub);
225 friend std::ostream &
228 using namespace print_helper;
243 os <<
"BoundingBox: " << labelStatistics.
m_BoundingBox << std::endl;
252 os <<
"nullptr" << std::endl;
271 using MapType = std::unordered_map<LabelPixelType, LabelStatistics>;
280 itkSetMacro(UseHistograms,
bool);
281 itkGetConstMacro(UseHistograms,
bool);
282 itkBooleanMacro(UseHistograms);
288 return m_ValidLabelValues;
301 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
308 return static_cast<MapSizeType>(m_LabelStatistics.size());
314 return static_cast<MapSizeType>(this->GetNumberOfObjects());
373 Superclass::SetNumberOfStreamDivisions(n);
378 return Superclass::GetNumberOfStreamDivisions();
382#ifdef ITK_USE_CONCEPT_CHECKING
397 this->AllocateOutputs();
398 m_LabelStatistics.clear();
416 bool m_UseHistograms{};
423 std::mutex m_Mutex{};
428#ifndef ITK_MANUAL_INSTANTIATION
429# include "itkLabelStatisticsImageFilter.hxx"
void SetSize(SizeValueType sz)
SmartPointer< Self > Pointer
typename InputImageType::Pointer InputImagePointer
Control indentation during Print() invocation.
Statistics stored per label.
HistogramType::Pointer m_Histogram
LabelStatistics(LabelStatistics &&)=default
LabelStatistics(const LabelStatistics &l)
LabelStatistics(int size, RealType lowerBound, RealType upperBound)
BoundingBoxType m_BoundingBox
LabelStatistics & operator=(const LabelStatistics &l)
Given an intensity image and a label map, compute min, max, variance and mean of the pixels associate...
void SetNumberOfStreamDivisions(const unsigned int n) override
~LabelStatisticsImageFilter() override=default
HistogramPointer GetHistogram(LabelPixelType label) const
RealType GetMean(LabelPixelType label) const
unsigned int GetNumberOfStreamDivisions() const override
IdentifierType MapSizeType
typename TLabelImage::RegionType LabelRegionType
typename MapType::iterator MapIterator
typename HistogramType::Pointer HistogramPointer
typename TInputImage::IndexType IndexType
TLabelImage LabelImageType
RealType GetSigma(LabelPixelType label) const
BoundingBoxType GetBoundingBox(LabelPixelType label) const
void MergeMap(MapType &, MapType &) const
MapSizeType GetCount(LabelPixelType label) const
typename TLabelImage::Pointer LabelImagePointer
RealType GetMinimum(LabelPixelType label) const
typename TInputImage::RegionType RegionType
RegionType GetRegion(LabelPixelType label) const
bool HasLabel(LabelPixelType label) const
typename TLabelImage::PixelType LabelPixelType
itkSetInputMacro(LabelInput, TLabelImage)
MapSizeType GetNumberOfObjects() const
std::vector< IndexValueType > BoundingBoxType
void AfterStreamedGenerateData() override
LabelStatisticsImageFilter()
MapSizeType GetNumberOfLabels() const
std::vector< LabelPixelType > ValidLabelValuesContainerType
typename TLabelImage::IndexType LabelIndexType
itkGetInputMacro(LabelInput, TLabelImage)
typename TLabelImage::SizeType LabelSizeType
RealType GetSum(LabelPixelType label) const
typename TInputImage::PixelType PixelType
RealType GetMaximum(LabelPixelType label) const
std::unordered_map< LabelPixelType, LabelStatistics > MapType
virtual const ValidLabelValuesContainerType & GetValidLabelValues() const
void BeforeStreamedGenerateData() override
typename TInputImage::SizeType SizeType
void PrintSelf(std::ostream &os, Indent indent) const override
RealType GetMedian(LabelPixelType label) const
typename NumericTraits< PixelType >::RealType RealType
void SetHistogramParameters(const int numBins, RealType lowerBound, RealType upperBound)
typename MapType::const_iterator MapConstIterator
void ThreadedStreamedGenerateData(const RegionType &) override
RealType GetVariance(LabelPixelType label) const
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
This class stores measurement vectors in the context of n-dimensional histogram.
Base class interface to process data on multiple requested input chunks.
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
ImageBaseType::SizeType SizeType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
SizeValueType IdentifierType