18 #ifndef itkLabelStatisticsImageFilter_h
19 #define itkLabelStatisticsImageFilter_h
24 #include "itksys/hash_map.hxx"
59 template<
typename TInputImage,
typename TLabelImage >
92 itkStaticConstMacro(ImageDimension,
unsigned int,
93 TInputImage::ImageDimension);
136 const unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
137 m_BoundingBox.resize(imageDimension * 2);
138 for (
unsigned int i = 0; i < imageDimension * 2; i += 2 )
143 m_Histogram = ITK_NULLPTR;
163 const unsigned int imageDimension = itkGetStaticConstMacro(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);
233 typedef itksys::hash_map< LabelPixelType, LabelStatistics >
MapType;
234 typedef typename itksys::hash_map< LabelPixelType, LabelStatistics >::iterator
MapIterator;
235 typedef typename itksys::hash_map< LabelPixelType, LabelStatistics >::const_iterator
MapConstIterator;
242 itkSetMacro(UseHistograms,
bool);
243 itkGetConstMacro(UseHistograms,
bool);
244 itkBooleanMacro(UseHistograms);
249 return m_ValidLabelValues;
256 this->SetNthInput( 1, const_cast< TLabelImage * >( input ) );
269 return m_LabelStatistics.find(label) != m_LabelStatistics.end();
275 return static_cast<MapSizeType>( m_LabelStatistics.size() );
280 return static_cast<MapSizeType>( this->GetNumberOfObjects() );
284 RealType GetMinimum(LabelPixelType label)
const;
287 RealType GetMaximum(LabelPixelType label)
const;
290 RealType GetMean(LabelPixelType label)
const;
294 RealType GetMedian(LabelPixelType label)
const;
297 RealType GetSigma(LabelPixelType label)
const;
300 RealType GetVariance(LabelPixelType label)
const;
305 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
308 RegionType GetRegion(LabelPixelType label)
const;
311 RealType GetSum(LabelPixelType label)
const;
314 MapSizeType GetCount(LabelPixelType label)
const;
317 HistogramPointer GetHistogram(LabelPixelType label)
const;
320 void SetHistogramParameters(
const int numBins, RealType lowerBound,
321 RealType upperBound);
323 #ifdef ITK_USE_CONCEPT_CHECKING
333 void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
337 void AllocateOutputs() ITK_OVERRIDE;
340 void BeforeThreadedGenerateData() ITK_OVERRIDE;
344 void AfterThreadedGenerateData() ITK_OVERRIDE;
347 void ThreadedGenerateData(const RegionType &
348 outputRegionForThread,
352 void EnlargeOutputRequestedRegion(
DataObject *data) ITK_OVERRIDE;
357 std::vector<
MapType > m_LabelStatisticsPerThread;
361 bool m_UseHistograms;
371 #ifndef ITK_MANUAL_INSTANTIATION
372 #include "itkLabelStatisticsImageFilter.hxx"
Critical section locking class that can be allocated on the stack.
itksys::hash_map< LabelPixelType, LabelStatistics >::iterator MapIterator
bool HasLabel(LabelPixelType label) const
void SetLabelInput(const TLabelImage *input)
Light weight base class for most itk classes.
itksys::hash_map< LabelPixelType, LabelStatistics > MapType
MapSizeType GetNumberOfObjects() const
MapSizeType GetNumberOfLabels() const
virtual const ValidLabelValuesContainerType & GetValidLabelValues() const
std::vector< IndexValueType > BoundingBoxType
TLabelImage::Pointer LabelImagePointer
NumericTraits< PixelType >::RealType RealType
SmartPointer< Self > Pointer
SimpleDataObjectDecorator< RealType > RealObjectType
TInputImage::SizeType SizeType
TLabelImage::SizeType LabelSizeType
This class stores measurement vectors in the context of n-dimensional histogram.
Given an intensity image and a label map, compute min, max, variance and mean of the pixels associate...
HistogramType::Pointer HistogramPointer
DataObject::Pointer DataObjectPointer
static ITK_CONSTEXPR_FUNC T max(const T &)
SizeValueType IdentifierType
Statistics stored per label.
TLabelImage::PixelType LabelPixelType
void SetSize(SizeValueType sz)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API...
TLabelImage::RegionType LabelRegionType
Superclass::MeasurementVectorType MeasurementVectorType
itk::Statistics::Histogram< RealType > HistogramType
~LabelStatisticsImageFilter() override
TInputImage::IndexType IndexType
LabelStatistics(const LabelStatistics &l)
BoundingBoxType m_BoundingBox
std::vector< LabelPixelType > ValidLabelValuesContainerType
unsigned int ThreadIdType
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itksys::hash_map< LabelPixelType, LabelStatistics >::const_iterator MapConstIterator
TInputImage::PixelType PixelType
TInputImage::Pointer InputImagePointer
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
SmartPointer< const Self > ConstPointer
TInputImage::RegionType RegionType
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
LabelStatisticsImageFilter Self
ImageBaseType::SizeType SizeType
Define additional traits for native types such as int or float.
TLabelImage LabelImageType
#define itkConceptMacro(name, concept)
HistogramType::Pointer m_Histogram
IdentifierType MapSizeType
Base class for all data objects in ITK.
ImageToImageFilter< TInputImage, TInputImage > Superclass
ImageBaseType::IndexType IndexType
TLabelImage::IndexType LabelIndexType