18 #ifndef itkLabelGeometryImageFilter_h
19 #define itkLabelGeometryImageFilter_h
27 #include "vnl/algo/vnl_symmetric_eigensystem.h"
28 #include "vnl/vnl_det.h"
80 template <
typename TLabelImage,
typename TIntensityImage = TLabelImage>
81 class 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);
198 unsigned int numberOfVertices = 1 << ImageDimension;
199 m_OrientedBoundingBoxVertices.resize(numberOfVertices, emptyPoint);
200 m_OrientedBoundingBoxVolume = 0;
201 m_OrientedBoundingBoxSize.Fill(0);
204 m_OrientedBoundingBoxOrigin.Fill(0);
205 m_RotationMatrix.set_size(ImageDimension, ImageDimension);
206 m_RotationMatrix.fill(0.0);
208 m_SecondOrderRawMoments.set_size(ImageDimension, ImageDimension);
209 m_SecondOrderCentralMoments.set_size(ImageDimension, ImageDimension);
210 for (
unsigned int i = 0; i < ImageDimension; ++i)
212 for (
unsigned int j = 0; j < ImageDimension; ++j)
214 m_SecondOrderRawMoments(i, j) = 0;
215 m_SecondOrderCentralMoments(i, j) = 0;
252 using MapType = std::map<LabelPixelType, LabelGeometry>;
253 using MapIterator =
typename std::map<LabelPixelType, LabelGeometry>::iterator;
257 itkGetMacro(CalculatePixelIndices,
bool);
258 itkBooleanMacro(CalculatePixelIndices);
268 if ((this->m_CalculateOrientedBoundingBox) || (this->m_CalculateOrientedLabelRegions) ||
269 (this->m_CalculateOrientedIntensityRegions))
276 if (this->m_CalculatePixelIndices != value)
278 this->m_CalculatePixelIndices = value;
283 itkGetMacro(CalculateOrientedBoundingBox,
bool);
284 itkBooleanMacro(CalculateOrientedBoundingBox);
287 if (this->m_CalculateOrientedBoundingBox != value)
289 this->m_CalculateOrientedBoundingBox = value;
297 this->SetCalculatePixelIndices(
true);
301 itkGetMacro(CalculateOrientedLabelRegions,
bool);
302 itkBooleanMacro(CalculateOrientedLabelRegions);
305 if (this->m_CalculateOrientedLabelRegions != value)
307 this->m_CalculateOrientedLabelRegions = value;
314 SetCalculateOrientedBoundingBox(
true);
319 itkGetMacro(CalculateOrientedIntensityRegions,
bool);
320 itkBooleanMacro(CalculateOrientedIntensityRegions);
323 if (this->m_CalculateOrientedIntensityRegions != value)
325 this->m_CalculateOrientedIntensityRegions = value;
332 this->SetCalculateOrientedBoundingBox(
true);
341 this->SetNthInput(1, const_cast<TIntensityImage *>(input));
360 std::vector<LabelPixelType>
GetLabels()
const {
return m_AllLabels; }
363 LabelIndicesType GetPixelIndices(LabelPixelType label)
const;
370 RealType GetIntegratedIntensity(LabelPixelType label)
const;
373 LabelPointType GetCentroid(LabelPixelType label)
const;
376 LabelPointType GetWeightedCentroid(LabelPixelType label)
const;
379 VectorType GetEigenvalues(LabelPixelType label)
const;
382 MatrixType GetEigenvectors(LabelPixelType label)
const;
385 AxesLengthType GetAxesLength(LabelPixelType label)
const;
389 RealType GetMinorAxisLength(LabelPixelType label)
const;
393 RealType GetMajorAxisLength(LabelPixelType label)
const;
396 RealType GetEccentricity(LabelPixelType label)
const;
400 RealType GetElongation(LabelPixelType label)
const;
403 RealType GetOrientation(LabelPixelType label)
const;
408 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
411 RealType GetBoundingBoxVolume(LabelPixelType label)
const;
414 LabelSizeType GetBoundingBoxSize(LabelPixelType label)
const;
422 BoundingBoxVerticesType GetOrientedBoundingBoxVertices(LabelPixelType label)
const;
425 RealType GetOrientedBoundingBoxVolume(LabelPixelType label)
const;
428 LabelPointType GetOrientedBoundingBoxSize(LabelPixelType label)
const;
431 LabelPointType GetOrientedBoundingBoxOrigin(LabelPixelType label)
const;
435 MatrixType GetRotationMatrix(LabelPixelType label)
const;
438 RegionType GetRegion(LabelPixelType label)
const;
441 TLabelImage * GetOrientedLabelImage(LabelPixelType label)
const;
445 TIntensityImage * GetOrientedIntensityImage(LabelPixelType label)
const;
447 #ifdef ITK_USE_CONCEPT_CHECKING
456 void PrintSelf(std::ostream & os,
Indent indent)
const override;
458 void GenerateData()
override;
461 bool CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<double> eig, LabelGeometry & m_LabelGeometry);
463 bool m_CalculatePixelIndices{};
464 bool m_CalculateOrientedBoundingBox{};
465 bool m_CalculateOrientedLabelRegions{};
466 bool m_CalculateOrientedIntensityRegions{};
475 #ifndef ITK_MANUAL_INSTANTIATION
476 # include "itkLabelGeometryImageFilter.hxx"