18 #ifndef itkLabelStatisticsImageFilter_h
19 #define itkLabelStatisticsImageFilter_h
26 #include <unordered_map>
61 template <
typename TInputImage,
typename TLabelImage>
95 static constexpr
unsigned int ImageDimension = TInputImage::ImageDimension;
137 const unsigned int imageDimension = Self::ImageDimension;
138 m_BoundingBox.resize(imageDimension * 2);
139 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
144 m_Histogram =
nullptr;
164 const unsigned int imageDimension = Self::ImageDimension;
165 m_BoundingBox.resize(imageDimension * 2);
166 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
180 m_Histogram->SetMeasurementVectorSize(1);
184 m_Histogram->Initialize(hsize, lb, ub);
237 using MapType = std::unordered_map<LabelPixelType, LabelStatistics>;
246 itkSetMacro(UseHistograms,
bool);
247 itkGetConstMacro(UseHistograms,
bool);
248 itkBooleanMacro(UseHistograms);
254 return m_ValidLabelValues;
258 itkSetInputMacro(LabelInput, TLabelImage);
259 itkGetInputMacro(LabelInput, TLabelImage);
267 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
274 return static_cast<MapSizeType>(m_LabelStatistics.size());
280 return static_cast<MapSizeType>(this->GetNumberOfObjects());
285 GetMinimum(LabelPixelType label)
const;
289 GetMaximum(LabelPixelType label)
const;
293 GetMean(LabelPixelType label)
const;
298 GetMedian(LabelPixelType label)
const;
302 GetSigma(LabelPixelType label)
const;
306 GetVariance(LabelPixelType label)
const;
312 GetBoundingBox(LabelPixelType label)
const;
316 GetRegion(LabelPixelType label)
const;
320 GetSum(LabelPixelType label)
const;
324 GetCount(LabelPixelType label)
const;
328 GetHistogram(LabelPixelType label)
const;
332 SetHistogramParameters(
const int numBins, RealType lowerBound, RealType upperBound);
339 Superclass::SetNumberOfStreamDivisions(n);
344 return Superclass::GetNumberOfStreamDivisions();
348 #ifdef ITK_USE_CONCEPT_CHECKING
358 PrintSelf(std::ostream & os,
Indent indent)
const override;
363 this->AllocateOutputs();
364 m_LabelStatistics.clear();
370 AfterStreamedGenerateData()
override;
373 ThreadedStreamedGenerateData(
const RegionType &)
override;
377 MergeMap(MapType &, MapType &)
const;
382 bool m_UseHistograms{};
389 std::mutex m_Mutex{};
394 #ifndef ITK_MANUAL_INSTANTIATION
395 # include "itkLabelStatisticsImageFilter.hxx"