diff --git a/Modules/ImageStatistics/mitkLabelStatisticsImageFilter.h b/Modules/ImageStatistics/mitkLabelStatisticsImageFilter.h index fe9beb7000..817418e2ce 100644 --- a/Modules/ImageStatistics/mitkLabelStatisticsImageFilter.h +++ b/Modules/ImageStatistics/mitkLabelStatisticsImageFilter.h @@ -1,168 +1,169 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ // This file is based on ITK's itkLabelStatisticsImageFilter.h #ifndef mitkLabelStatisticsImageFilter_h #define mitkLabelStatisticsImageFilter_h #include #include #include #include #include #include #include #include #include namespace mitk { template class LabelStatisticsImageFilter : public itk::ImageSink { public: using Self = LabelStatisticsImageFilter; using Superclass = itk::ImageSink; using Pointer = itk::SmartPointer; using ConstPointer = itk::SmartPointer; itkFactorylessNewMacro(Self); itkTypeMacro(LabelStatisticsImageFilter, itk::ImageSink); using IndexType = typename TInputImage::IndexType; using SizeType = typename TInputImage::SizeType; using RegionType = typename TInputImage::RegionType; using PixelType = typename TInputImage::PixelType; using LabelPixelType = typename mitk::Label::PixelType; static constexpr unsigned int ImageDimension = TInputImage::ImageDimension; using RealType = typename itk::NumericTraits::RealType; using DataObjectPointer = typename itk::DataObject::Pointer; using RealObjectType = itk::SimpleDataObjectDecorator; using BoundingBoxType = std::vector; using HistogramType = itk::Statistics::Histogram; using HistogramPointer = typename HistogramType::Pointer; class LabelStatistics { public: LabelStatistics(); LabelStatistics(unsigned int size, RealType lowerBound, RealType upperBound); ~LabelStatistics(); itk::SizeValueType m_Count; itk::SizeValueType m_CountOfPositivePixels; RealType m_Min; RealType m_Max; RealType m_Mean; itk::CompensatedSummation m_Sum; itk::CompensatedSummation m_SumOfPositivePixels; itk::CompensatedSummation m_SumOfSquares; itk::CompensatedSummation m_SumOfCubes; itk::CompensatedSummation m_SumOfQuadruples; RealType m_Sigma; RealType m_Variance; RealType m_MPP; RealType m_Median; RealType m_Uniformity; RealType m_UPP; RealType m_Entropy; RealType m_Skewness; RealType m_Kurtosis; BoundingBoxType m_BoundingBox; HistogramPointer m_Histogram; }; using MapType = std::unordered_map; using MapIterator = typename MapType::iterator; using MapConstIterator = typename MapType::const_iterator; using ValidLabelValuesContainerType = std::vector; const ValidLabelValuesContainerType& GetValidLabelValues() const; void SetHistogramParameters( const std::unordered_map& sizes, const std::unordered_map& lowerBounds, const std::unordered_map& upperBounds); using LabelImageType = itk::Image; + using ProcessObject = itk::ProcessObject; itkSetInputMacro(LabelInput, LabelImageType); itkGetInputMacro(LabelInput, LabelImageType); bool HasLabel(LabelPixelType label) const; unsigned int GetNumberOfObjects() const; unsigned int GetNumberOfLabels() const; PixelType GetMinimum(LabelPixelType label) const; PixelType GetMaximum(LabelPixelType label) const; RealType GetMean(LabelPixelType label) const; RealType GetSigma(LabelPixelType label) const; RealType GetVariance(LabelPixelType label) const; BoundingBoxType GetBoundingBox(LabelPixelType label) const; RegionType GetRegion(LabelPixelType label) const; RealType GetSum(LabelPixelType label) const; RealType GetSumOfSquares(LabelPixelType label) const; RealType GetSumOfCubes(LabelPixelType label) const; RealType GetSumOfQuadruples(LabelPixelType label) const; RealType GetSkewness(LabelPixelType label) const; RealType GetKurtosis(LabelPixelType label) const; RealType GetMPP(LabelPixelType label) const; itk::SizeValueType GetCount(LabelPixelType label) const; HistogramPointer GetHistogram(LabelPixelType label) const; RealType GetEntropy(LabelPixelType label) const; RealType GetUniformity(LabelPixelType label) const; RealType GetUPP(LabelPixelType label) const; RealType GetMedian(LabelPixelType label) const; protected: LabelStatisticsImageFilter(); ~LabelStatisticsImageFilter(); void BeforeStreamedGenerateData() override; void ThreadedStreamedGenerateData(const RegionType&) override; void AfterStreamedGenerateData() override; void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: const LabelStatistics& GetLabelStatistics(LabelPixelType label) const; const LabelStatistics& GetLabelHistogramStatistics(LabelPixelType label) const; void MergeMap(MapType& map1, MapType& map2) const; MapType m_LabelStatistics; ValidLabelValuesContainerType m_ValidLabelValues; bool m_ComputeHistograms; std::unordered_map m_HistogramSizes; std::unordered_map m_HistogramLowerBounds; std::unordered_map m_HistogramUpperBounds; std::mutex m_Mutex; }; } #ifndef ITK_MANUAL_INSTANTIATION #include #endif #endif diff --git a/Modules/ImageStatistics/mitkStatisticsImageFilter.h b/Modules/ImageStatistics/mitkStatisticsImageFilter.h index d971f0ea50..54abfc4cf3 100644 --- a/Modules/ImageStatistics/mitkStatisticsImageFilter.h +++ b/Modules/ImageStatistics/mitkStatisticsImageFilter.h @@ -1,142 +1,143 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ // This file is based on ITK's itkStatisticsImageFilter.h #ifndef mitkStatisticsImageFilter #define mitkStatisticsImageFilter #include #include #include #include #include #include #include #include namespace mitk { template class StatisticsImageFilter : public itk::ImageSink { public: using Self = StatisticsImageFilter; using Superclass = itk::ImageSink; using Pointer = itk::SmartPointer; using ConstPointer = itk::SmartPointer; itkFactorylessNewMacro(Self); itkTypeMacro(StatisticsImageFilter, itk::ImageSink); using RegionType = typename TInputImage::RegionType; using PixelType = typename TInputImage::PixelType; using RealType = typename itk::NumericTraits::RealType; using HistogramType = typename itk::Statistics::Histogram; using HistogramPointer = itk::SmartPointer; using DataObjectPointer = typename itk::DataObject::Pointer; template using SimpleDataObjectDecorator = itk::SimpleDataObjectDecorator; using RealObjectType = SimpleDataObjectDecorator; using PixelObjectType = SimpleDataObjectDecorator; + using ProcessObject = itk::ProcessObject; itkGetDecoratedOutputMacro(Minimum, PixelType); itkGetDecoratedOutputMacro(Maximum, PixelType); itkGetDecoratedOutputMacro(Mean, RealType); itkGetDecoratedOutputMacro(Sigma, RealType); itkGetDecoratedOutputMacro(Variance, RealType); itkGetDecoratedOutputMacro(Sum, RealType); itkGetDecoratedOutputMacro(SumOfSquares, RealType); itkGetDecoratedOutputMacro(SumOfCubes, RealType); itkGetDecoratedOutputMacro(SumOfQuadruples, RealType); itkGetDecoratedOutputMacro(Skewness, RealType); itkGetDecoratedOutputMacro(Kurtosis, RealType); itkGetDecoratedOutputMacro(MPP, RealType); itkGetDecoratedOutputMacro(Histogram, HistogramPointer); itkGetDecoratedOutputMacro(Entropy, RealType); itkGetDecoratedOutputMacro(Uniformity, RealType); itkGetDecoratedOutputMacro(UPP, RealType); itkGetDecoratedOutputMacro(Median, RealType); void SetHistogramParameters(unsigned int size, RealType lowerBound, RealType upperBound); using DataObjectIdentifierType = itk::ProcessObject::DataObjectIdentifierType; using Superclass::MakeOutput; /** Make a DataObject of the correct type to be used as the specified output. */ DataObjectPointer MakeOutput(const DataObjectIdentifierType& name) override; protected: StatisticsImageFilter(); ~StatisticsImageFilter(); itkSetDecoratedOutputMacro(Minimum, PixelType); itkSetDecoratedOutputMacro(Maximum, PixelType); itkSetDecoratedOutputMacro(Mean, RealType); itkSetDecoratedOutputMacro(Sigma, RealType); itkSetDecoratedOutputMacro(Variance, RealType); itkSetDecoratedOutputMacro(Sum, RealType); itkSetDecoratedOutputMacro(SumOfSquares, RealType); itkSetDecoratedOutputMacro(SumOfCubes, RealType); itkSetDecoratedOutputMacro(SumOfQuadruples, RealType); itkSetDecoratedOutputMacro(Skewness, RealType); itkSetDecoratedOutputMacro(Kurtosis, RealType); itkSetDecoratedOutputMacro(MPP, RealType); itkSetDecoratedOutputMacro(Histogram, HistogramPointer); itkSetDecoratedOutputMacro(Entropy, RealType); itkSetDecoratedOutputMacro(Uniformity, RealType); itkSetDecoratedOutputMacro(UPP, RealType); itkSetDecoratedOutputMacro(Median, RealType); void BeforeStreamedGenerateData() override; void ThreadedStreamedGenerateData(const RegionType&) override; void AfterStreamedGenerateData() override; void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HistogramPointer CreateInitializedHistogram() const; bool m_ComputeHistogram; unsigned int m_HistogramSize; RealType m_HistogramLowerBound; RealType m_HistogramUpperBound; HistogramPointer m_Histogram; itk::CompensatedSummation m_Sum; itk::CompensatedSummation m_SumOfPositivePixels; itk::CompensatedSummation m_SumOfSquares; itk::CompensatedSummation m_SumOfCubes; itk::CompensatedSummation m_SumOfQuadruples; itk::SizeValueType m_Count; itk::SizeValueType m_CountOfPositivePixels; PixelType m_Min; PixelType m_Max; std::mutex m_Mutex; }; } #ifndef ITK_MANUAL_INSTANTIATION #include #endif #endif