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);
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);
288 if (this->m_CalculateOrientedBoundingBox != value)
290 this->m_CalculateOrientedBoundingBox = value;
298 this->SetCalculatePixelIndices(
true);
302 itkGetMacro(CalculateOrientedLabelRegions,
bool);
303 itkBooleanMacro(CalculateOrientedLabelRegions);
307 if (this->m_CalculateOrientedLabelRegions != value)
309 this->m_CalculateOrientedLabelRegions = value;
316 SetCalculateOrientedBoundingBox(
true);
321 itkGetMacro(CalculateOrientedIntensityRegions,
bool);
322 itkBooleanMacro(CalculateOrientedIntensityRegions);
326 if (this->m_CalculateOrientedIntensityRegions != value)
328 this->m_CalculateOrientedIntensityRegions = value;
335 this->SetCalculateOrientedBoundingBox(
true);
345 this->SetNthInput(1, const_cast<TIntensityImage *>(input));
349 const TIntensityImage *
360 return m_LabelGeometryMapper.find(label) != m_LabelGeometryMapper.end();
367 return m_LabelGeometryMapper.size();
373 return this->GetNumberOfObjects();
377 std::vector<LabelPixelType>
385 GetPixelIndices(LabelPixelType label)
const;
390 GetVolume(LabelPixelType label)
const;
394 GetIntegratedIntensity(LabelPixelType label)
const;
398 GetCentroid(LabelPixelType label)
const;
402 GetWeightedCentroid(LabelPixelType label)
const;
406 GetEigenvalues(LabelPixelType label)
const;
410 GetEigenvectors(LabelPixelType label)
const;
414 GetAxesLength(LabelPixelType label)
const;
419 GetMinorAxisLength(LabelPixelType label)
const;
424 GetMajorAxisLength(LabelPixelType label)
const;
428 GetEccentricity(LabelPixelType label)
const;
433 GetElongation(LabelPixelType label)
const;
437 GetOrientation(LabelPixelType label)
const;
443 GetBoundingBox(LabelPixelType label)
const;
447 GetBoundingBoxVolume(LabelPixelType label)
const;
451 GetBoundingBoxSize(LabelPixelType label)
const;
459 BoundingBoxVerticesType
460 GetOrientedBoundingBoxVertices(LabelPixelType label)
const;
464 GetOrientedBoundingBoxVolume(LabelPixelType label)
const;
468 GetOrientedBoundingBoxSize(LabelPixelType label)
const;
472 GetOrientedBoundingBoxOrigin(LabelPixelType label)
const;
477 GetRotationMatrix(LabelPixelType label)
const;
481 GetRegion(LabelPixelType label)
const;
485 GetOrientedLabelImage(LabelPixelType label)
const;
490 GetOrientedIntensityImage(LabelPixelType label)
const;
492 #ifdef ITK_USE_CONCEPT_CHECKING
502 PrintSelf(std::ostream & os,
Indent indent)
const override;
505 GenerateData()
override;
509 CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<double> eig, LabelGeometry & m_LabelGeometry);
511 bool m_CalculatePixelIndices{};
512 bool m_CalculateOrientedBoundingBox{};
513 bool m_CalculateOrientedLabelRegions{};
514 bool m_CalculateOrientedIntensityRegions{};
523 #ifndef ITK_MANUAL_INSTANTIATION
524 # include "itkLabelGeometryImageFilter.hxx"