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);
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; }
362 LabelIndicesType GetPixelIndices(LabelPixelType label)
const;
369 RealType GetIntegratedIntensity(LabelPixelType label)
const;
372 LabelPointType GetCentroid(LabelPixelType label)
const;
375 LabelPointType GetWeightedCentroid(LabelPixelType label)
const;
378 VectorType GetEigenvalues(LabelPixelType label)
const;
381 MatrixType GetEigenvectors(LabelPixelType label)
const;
384 AxesLengthType GetAxesLength(LabelPixelType label)
const;
388 RealType GetMinorAxisLength(LabelPixelType label)
const;
392 RealType GetMajorAxisLength(LabelPixelType label)
const;
395 RealType GetEccentricity(LabelPixelType label)
const;
399 RealType GetElongation(LabelPixelType label)
const;
402 RealType GetOrientation(LabelPixelType label)
const;
407 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
410 RealType GetBoundingBoxVolume(LabelPixelType label)
const;
413 LabelSizeType GetBoundingBoxSize(LabelPixelType label)
const;
421 BoundingBoxVerticesType GetOrientedBoundingBoxVertices(LabelPixelType label)
const;
424 RealType GetOrientedBoundingBoxVolume(LabelPixelType label)
const;
427 LabelPointType GetOrientedBoundingBoxSize(LabelPixelType label)
const;
430 LabelPointType GetOrientedBoundingBoxOrigin(LabelPixelType label)
const;
434 MatrixType GetRotationMatrix(LabelPixelType label)
const;
437 RegionType GetRegion(LabelPixelType label)
const;
440 TLabelImage * GetOrientedLabelImage(LabelPixelType label)
const;
444 TIntensityImage * GetOrientedIntensityImage(LabelPixelType label)
const;
446 #ifdef ITK_USE_CONCEPT_CHECKING
455 void PrintSelf(std::ostream & os,
Indent indent)
const override;
457 void GenerateData()
override;
460 bool CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<double> eig, LabelGeometry & m_LabelGeometry);
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"