18 #ifndef itkLabelStatisticsImageFilter_h
19 #define itkLabelStatisticsImageFilter_h
26 #include <unordered_map>
58 template<
typename TInputImage,
typename TLabelImage >
93 static constexpr
unsigned int ImageDimension = TInputImage::ImageDimension;
136 const unsigned int imageDimension = Self::ImageDimension;
137 m_BoundingBox.resize(imageDimension * 2);
138 for (
unsigned int i = 0; i < imageDimension * 2; i += 2 )
143 m_Histogram =
nullptr;
163 const unsigned int imageDimension = Self::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);
235 using MapType = std::unordered_map< LabelPixelType, LabelStatistics >;
244 itkSetMacro(UseHistograms,
bool);
245 itkGetConstMacro(UseHistograms,
bool);
246 itkBooleanMacro(UseHistograms);
251 return m_ValidLabelValues;
258 this->SetNthInput( 1, const_cast< TLabelImage * >( input ) );
271 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
277 return static_cast<MapSizeType>( m_LabelStatistics.size() );
282 return static_cast<MapSizeType>( this->GetNumberOfObjects() );
286 RealType GetMinimum(LabelPixelType label)
const;
289 RealType GetMaximum(LabelPixelType label)
const;
292 RealType GetMean(LabelPixelType label)
const;
296 RealType GetMedian(LabelPixelType label)
const;
299 RealType GetSigma(LabelPixelType label)
const;
302 RealType GetVariance(LabelPixelType label)
const;
307 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
310 RegionType GetRegion(LabelPixelType label)
const;
313 RealType GetSum(LabelPixelType label)
const;
316 MapSizeType GetCount(LabelPixelType label)
const;
319 HistogramPointer GetHistogram(LabelPixelType label)
const;
322 void SetHistogramParameters(
const int numBins, RealType lowerBound,
323 RealType upperBound);
325 #ifdef ITK_USE_CONCEPT_CHECKING
335 void PrintSelf(std::ostream & os,
Indent indent)
const override;
339 void AllocateOutputs()
override;
343 void AfterThreadedGenerateData()
override;
345 void DynamicThreadedGenerateData(
const RegionType & )
override;
348 void EnlargeOutputRequestedRegion(
DataObject *data)
override;
352 void MergeMap( MapType &, MapType &)
const;
369 #ifndef ITK_MANUAL_INSTANTIATION
370 #include "itkLabelStatisticsImageFilter.hxx"
bool HasLabel(LabelPixelType label) const
IdentifierType MapSizeType
void SetLabelInput(const TLabelImage *input)
Light weight base class for most itk classes.
MapSizeType GetNumberOfObjects() const
MapSizeType GetNumberOfLabels() const
virtual const ValidLabelValuesContainerType & GetValidLabelValues() const
typename MapType::iterator MapIterator
Define numeric traits for std::vector.
typename TInputImage::PixelType PixelType
This class stores measurement vectors in the context of n-dimensional histogram.
typename NumericTraits< PixelType >::RealType RealType
Given an intensity image and a label map, compute min, max, variance and mean of the pixels associate...
TLabelImage LabelImageType
typename TInputImage::RegionType RegionType
typename TLabelImage::RegionType LabelRegionType
typename TLabelImage::PixelType LabelPixelType
typename HistogramType::Pointer HistogramPointer
typename TInputImage::SizeType SizeType
HistogramType::SizeType m_NumBins
Statistics stored per label.
void SetSize(SizeValueType sz)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API...
ImageBaseType::SizeType SizeType
typename TLabelImage::SizeType LabelSizeType
SizeValueType IdentifierType
MapType m_LabelStatistics
std::vector< LabelPixelType > ValidLabelValuesContainerType
ImageBaseType::IndexType IndexType
LabelStatistics(const LabelStatistics &l)
typename MapType::const_iterator MapConstIterator
ValidLabelValuesContainerType m_ValidLabelValues
BoundingBoxType m_BoundingBox
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
std::unordered_map< LabelPixelType, LabelStatistics > MapType
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
typename Superclass::MeasurementVectorType MeasurementVectorType
typename TLabelImage::Pointer LabelImagePointer
typename TLabelImage::IndexType LabelIndexType
typename TInputImage::IndexType IndexType
typename TInputImage::Pointer InputImagePointer
ImageBaseType::RegionType RegionType
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
HistogramType::Pointer m_Histogram
Base class for all data objects in ITK.
std::vector< IndexValueType > BoundingBoxType