18 #ifndef itkLabelStatisticsImageFilter_h
19 #define itkLabelStatisticsImageFilter_h
27 #include <unordered_map>
62 template <
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;
292 itkSetInputMacro(LabelInput, TLabelImage);
293 itkGetInputMacro(LabelInput, TLabelImage);
301 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
308 return static_cast<MapSizeType>(m_LabelStatistics.size());
314 return static_cast<MapSizeType>(this->GetNumberOfObjects());
319 GetMinimum(LabelPixelType label)
const;
323 GetMaximum(LabelPixelType label)
const;
327 GetMean(LabelPixelType label)
const;
332 GetMedian(LabelPixelType label)
const;
336 GetSigma(LabelPixelType label)
const;
340 GetVariance(LabelPixelType label)
const;
346 GetBoundingBox(LabelPixelType label)
const;
350 GetRegion(LabelPixelType label)
const;
354 GetSum(LabelPixelType label)
const;
358 GetCount(LabelPixelType label)
const;
362 GetHistogram(LabelPixelType label)
const;
366 SetHistogramParameters(
const int numBins, RealType lowerBound, RealType upperBound);
373 Superclass::SetNumberOfStreamDivisions(n);
378 return Superclass::GetNumberOfStreamDivisions();
382 #ifdef ITK_USE_CONCEPT_CHECKING
392 PrintSelf(std::ostream & os,
Indent indent)
const override;
397 this->AllocateOutputs();
398 m_LabelStatistics.clear();
404 AfterStreamedGenerateData()
override;
407 ThreadedStreamedGenerateData(
const RegionType &)
override;
411 MergeMap(MapType &, MapType &)
const;
416 bool m_UseHistograms{};
423 std::mutex m_Mutex{};
428 #ifndef ITK_MANUAL_INSTANTIATION
429 # include "itkLabelStatisticsImageFilter.hxx"