18#ifndef itkLabelGeometryImageFilter_h
19#define itkLabelGeometryImageFilter_h
27#include "vnl/algo/vnl_symmetric_eigensystem.h"
28#include "vnl/vnl_det.h"
80template <
typename TLabelImage,
typename TIntensityImage = TLabelImage>
81class ITK_TEMPLATE_EXPORT
82#if !defined(ITK_LEGACY_SILENT)
83 [[deprecated("This class contains known computational bugs. See class documentation for details.")]]
120 static constexpr unsigned int ImageDimension = TLabelImage::ImageDimension;
171 const unsigned int imageDimension = Self::ImageDimension;
174 for (
unsigned int i = 0; i < imageDimension * 2; i += 2)
180 m_BoundingBoxVolume = 0;
181 m_BoundingBoxSize.Fill(0);
182 m_PixelIndices.clear();
184 m_WeightedCentroid.Fill(0);
185 m_ZeroOrderMoment = 0;
186 m_FirstOrderRawMoments.Fill(0);
187 m_FirstOrderWeightedRawMoments.Fill(0);
188 m_Eigenvalues.resize(ImageDimension);
189 m_Eigenvalues.clear();
190 m_Eigenvectors.set_size(ImageDimension, ImageDimension);
191 m_Eigenvectors.fill(0);
192 m_AxesLength.Fill(0);
197 unsigned int numberOfVertices = 1 << ImageDimension;
198 m_OrientedBoundingBoxVertices.resize(numberOfVertices, emptyPoint);
199 m_OrientedBoundingBoxVolume = 0;
200 m_OrientedBoundingBoxSize.Fill(0);
203 m_OrientedBoundingBoxOrigin.Fill(0);
204 m_RotationMatrix.set_size(ImageDimension, ImageDimension);
205 m_RotationMatrix.fill(0.0);
207 m_SecondOrderRawMoments.set_size(ImageDimension, ImageDimension);
208 m_SecondOrderCentralMoments.set_size(ImageDimension, ImageDimension);
209 for (
unsigned int i = 0; i < ImageDimension; ++i)
211 for (
unsigned int j = 0; j < ImageDimension; ++j)
213 m_SecondOrderRawMoments(i, j) = 0;
214 m_SecondOrderCentralMoments(i, j) = 0;
251 using MapType = std::map<LabelPixelType, LabelGeometry>;
252 using MapIterator =
typename std::map<LabelPixelType, LabelGeometry>::iterator;
256 itkGetMacro(CalculatePixelIndices,
bool);
257 itkBooleanMacro(CalculatePixelIndices);
267 if ((this->m_CalculateOrientedBoundingBox) || (this->m_CalculateOrientedLabelRegions) ||
268 (this->m_CalculateOrientedIntensityRegions))
275 if (this->m_CalculatePixelIndices != value)
277 this->m_CalculatePixelIndices = value;
282 itkGetMacro(CalculateOrientedBoundingBox,
bool);
283 itkBooleanMacro(CalculateOrientedBoundingBox);
286 if (this->m_CalculateOrientedBoundingBox != value)
288 this->m_CalculateOrientedBoundingBox = value;
296 this->SetCalculatePixelIndices(
true);
300 itkGetMacro(CalculateOrientedLabelRegions,
bool);
301 itkBooleanMacro(CalculateOrientedLabelRegions);
304 if (this->m_CalculateOrientedLabelRegions != value)
306 this->m_CalculateOrientedLabelRegions = value;
313 SetCalculateOrientedBoundingBox(
true);
318 itkGetMacro(CalculateOrientedIntensityRegions,
bool);
319 itkBooleanMacro(CalculateOrientedIntensityRegions);
322 if (this->m_CalculateOrientedIntensityRegions != value)
324 this->m_CalculateOrientedIntensityRegions = value;
331 this->SetCalculateOrientedBoundingBox(
true);
340 this->SetNthInput(1,
const_cast<TIntensityImage *
>(input));
359 std::vector<LabelPixelType>
GetLabels()
const {
return m_AllLabels; }
446#ifdef ITK_USE_CONCEPT_CHECKING
462 bool m_CalculatePixelIndices{};
463 bool m_CalculateOrientedBoundingBox{};
464 bool m_CalculateOrientedLabelRegions{};
465 bool m_CalculateOrientedIntensityRegions{};
474#ifndef ITK_MANUAL_INSTANTIATION
475# include "itkLabelGeometryImageFilter.hxx"
Base class for all data objects in ITK.
SmartPointer< Self > Pointer
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Geometry stored per label.
MatrixType m_Eigenvectors
LabelIndicesType m_PixelIndices
SizeValueType m_FirstOrderRawCrossMoment
MatrixType m_SecondOrderCentralMoments
SizeValueType m_ZeroOrderMoment
RealType m_OrientedBoundingBoxVolume
LabelPointType m_OrientedBoundingBoxSize
MatrixType m_RotationMatrix
RealType m_BoundingBoxVolume
FixedArray< float, Self::ImageDimension > m_AxesLength
AxesLengthType m_FirstOrderWeightedRawMoments
LabelSizeType m_BoundingBoxSize
LabelPointType m_Centroid
IntensityImageType::Pointer m_OrientedIntensityImage
RealType m_FirstOrderCentralCrossMoment
LabelPointType m_OrientedBoundingBoxOrigin
LabelImageType::Pointer m_OrientedLabelImage
BoundingBoxVerticesType m_OrientedBoundingBoxVertices
MatrixType m_SecondOrderRawMoments
BoundingBoxType m_BoundingBox
LabelPointType m_WeightedCentroid
IndexArrayType m_FirstOrderRawMoments
Given a label map and an optional intensity image, compute geometric features.
typename TLabelImage::RegionType LabelRegionType
void SetCalculateOrientedIntensityRegions(const bool value)
RealType GetMajorAxisLength(LabelPixelType label) const
const TIntensityImage * GetIntensityInput() const
RealType GetElongation(LabelPixelType label) const
typename std::map< LabelPixelType, LabelGeometry >::iterator MapIterator
LabelSizeType GetBoundingBoxSize(LabelPixelType label) const
VectorType GetEigenvalues(LabelPixelType label) const
typename TLabelImage::SizeType LabelSizeType
typename TIntensityImage::SizeType SizeType
typename TIntensityImage::Pointer InputImagePointer
void GenerateData() override
RealType GetEccentricity(LabelPixelType label) const
std::vector< double > VectorType
TIntensityImage IntensityImageType
void SetCalculateOrientedBoundingBox(const bool value)
typename TIntensityImage::PixelType PixelType
typename TLabelImage::Pointer LabelImagePointer
LabelPointType GetCentroid(LabelPixelType label) const
void PrintSelf(std::ostream &os, Indent indent) const override
BoundingBoxVerticesType GetOrientedBoundingBoxVertices(LabelPixelType label) const
std::vector< LabelPixelType > LabelsType
LabelIndicesType GetPixelIndices(LabelPixelType label) const
typename TLabelImage::PixelType LabelPixelType
bool CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem< double > eig, LabelGeometry &m_LabelGeometry)
std::vector< LabelPixelType > GetLabels() const
std::vector< LabelPointType > BoundingBoxVerticesType
RealType GetIntegratedIntensity(LabelPixelType label) const
void SetCalculatePixelIndices(const bool value)
SizeValueType GetVolume(LabelPixelType label) const
MatrixType GetRotationMatrix(LabelPixelType label) const
SizeValueType GetNumberOfObjects() const
AxesLengthType GetAxesLength(LabelPixelType label) const
typename TIntensityImage::IndexType IndexType
RealType GetBoundingBoxVolume(LabelPixelType label) const
TLabelImage * GetOrientedLabelImage(LabelPixelType label) const
bool HasLabel(LabelPixelType label) const
LabelPointType GetWeightedCentroid(LabelPixelType label) const
TIntensityImage * GetOrientedIntensityImage(LabelPixelType label) const
SizeValueType GetNumberOfLabels() const
typename TIntensityImage::RegionType RegionType
RealType GetOrientedBoundingBoxVolume(LabelPixelType label) const
vnl_matrix< double > MatrixType
RealType GetMinorAxisLength(LabelPixelType label) const
MatrixType GetEigenvectors(LabelPixelType label) const
BoundingBoxType GetBoundingBox(LabelPixelType label) const
LabelGeometryImageFilter()
typename TLabelImage::PointType LabelPointType
LabelPointType GetOrientedBoundingBoxSize(LabelPixelType label) const
std::vector< LabelIndexType > LabelIndicesType
typename TLabelImage::IndexType LabelIndexType
typename std::map< LabelPixelType, LabelGeometry >::const_iterator MapConstIterator
std::map< LabelPixelType, LabelGeometry > MapType
void SetIntensityInput(const TIntensityImage *input)
~LabelGeometryImageFilter() override=default
LabelPointType GetOrientedBoundingBoxOrigin(LabelPixelType label) const
TLabelImage LabelImageType
void SetCalculateOrientedLabelRegions(const bool value)
RealType GetOrientation(LabelPixelType label) const
typename NumericTraits< PixelType >::RealType RealType
RegionType GetRegion(LabelPixelType label) const
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
ImageBaseType::PointType PointType
ImageBaseType::SizeType SizeType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType