18#ifndef itkVectorGradientMagnitudeImageFilter_h
19#define itkVectorGradientMagnitudeImageFilter_h
25#include "vnl/vnl_matrix.h"
26#include "vnl/vnl_vector_fixed.h"
27#include "vnl/algo/vnl_symmetric_eigensystem.h"
130template <
typename TInputImage,
131 typename TRealType = float,
201 itkGetConstMacro(UseImageSpacing,
bool);
202 itkBooleanMacro(UseImageSpacing);
204#if !defined(ITK_FUTURE_LEGACY_REMOVE)
211 SetUseImageSpacingOn()
221 SetUseImageSpacingOff()
223 this->SetUseImageSpacing(
false);
229#if !defined(ITK_LEGACY_REMOVE)
230 using WeightsType [[deprecated(
"Use DerivativeWeightsType or ComponentWeightsType instead.")]] =
ComponentWeightsType;
251 itkSetMacro(UsePrincipleComponents,
bool);
252 itkGetConstMacro(UsePrincipleComponents,
bool);
253 itkBooleanMacro(UsePrincipleComponents);
255#if !defined(ITK_FUTURE_LEGACY_REMOVE)
258 SetUsePrincipleComponentsOn()
265 SetUsePrincipleComponentsOff()
267 this->SetUsePrincipleComponents(
false);
319 TRealType sum = TRealType{};
328 return std::sqrt(accum);
340 vnl_vector_fixed<TRealType, VectorDimension> d_phi_du[TInputImage::ImageDimension];
358 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
365 CharEqn[2] = -(g[0][0] + g[1][1] + g[2][2]);
367 CharEqn[1] = (g[0][0] * g[1][1] + g[0][0] * g[2][2] + g[1][1] * g[2][2]) -
368 (g[0][1] * g[1][0] + g[0][2] * g[2][0] + g[1][2] * g[2][1]);
370 CharEqn[0] = g[0][0] * (g[1][2] * g[2][1] - g[1][1] * g[2][2]) + g[1][0] * (g[2][2] * g[0][1] - g[0][2] * g[2][1]) +
371 g[2][0] * (g[1][1] * g[0][2] - g[0][1] * g[1][2]);
374 const int numberOfDistinctRoots = this->
CubicSolver(CharEqn, Lambda);
378 if (numberOfDistinctRoots == 3)
380 if (Lambda[0] > Lambda[1])
382 if (Lambda[1] > Lambda[2])
384 ans = Lambda[0] - Lambda[1];
388 if (Lambda[0] > Lambda[2])
390 ans = Lambda[0] - Lambda[2];
394 ans = Lambda[2] - Lambda[0];
400 if (Lambda[0] > Lambda[2])
402 ans = Lambda[1] - Lambda[0];
406 if (Lambda[1] > Lambda[2])
408 ans = Lambda[1] - Lambda[2];
412 ans = Lambda[2] - Lambda[1];
417 else if (numberOfDistinctRoots == 2)
419 if (Lambda[0] > Lambda[1])
421 ans = Lambda[0] - Lambda[1];
425 ans = Lambda[1] - Lambda[0];
428 else if (numberOfDistinctRoots == 1)
434 itkExceptionMacro(
"Undefined condition. Cubic root solver returned " << numberOfDistinctRoots
435 <<
" distinct roots.");
448 vnl_vector_fixed<TRealType, VectorDimension> d_phi_du[TInputImage::ImageDimension];
466 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
471 const vnl_symmetric_eigensystem<TRealType> E(g);
498#ifndef ITK_MANUAL_INSTANTIATION
499# include "itkVectorGradientMagnitudeImageFilter.hxx"
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
itk::Size< VDimension > RadiusType
PixelType GetPrevious(const unsigned int axis, NeighborIndexType i) const
PixelType GetNext(const unsigned int axis, NeighborIndexType i) const
Simulate a standard C array with copy semantics.
static constexpr FixedArray Filled(const ValueType &value)
typename OutputImageType::RegionType OutputImageRegionType
Templated n-dimensional image class.
SmartPointer< const Self > ConstPointer
Control indentation during Print() invocation.
Implements transparent reference counting.
void SetUseImageSpacing(bool)
bool m_UsePrincipleComponents
TOutputImage OutputImageType
static constexpr unsigned int VectorDimension
~VectorGradientMagnitudeImageFilter() override=default
typename OutputImageType::Pointer OutputImagePointer
void PrintSelf(std::ostream &os, Indent indent) const override
Image< RealVectorType, TInputImage::ImageDimension > RealVectorImageType
TRealType EvaluateAtNeighborhood3D(const ConstNeighborhoodIteratorType &it) const
VectorGradientMagnitudeImageFilter()
typename OutputImageType::RegionType OutputImageRegionType
static constexpr unsigned int InputImageDimension
ConstNeighborhoodIterator< RealVectorImageType > ConstNeighborhoodIteratorType
ComponentWeightsType m_SqrtComponentWeights
TInputImage InputImageType
RealVectorImageType::ConstPointer m_RealValuedInputImage
virtual void SetUsePrincipleComponents(bool _arg)
DerivativeWeightsType m_DerivativeWeights
static int CubicSolver(const double *, double *)
FixedArray< TRealType, ImageDimension > DerivativeWeightsType
typename TInputImage::PixelType InputPixelType
void GenerateInputRequestedRegion() override
typename TOutputImage::PixelType OutputPixelType
typename ConstNeighborhoodIteratorType::RadiusType RadiusType
SmartPointer< const Self > ConstPointer
typename InputImageType::Pointer InputImagePointer
TRealType EvaluateAtNeighborhood(const ConstNeighborhoodIteratorType &it) const
void BeforeThreadedGenerateData() override
ComponentWeightsType m_ComponentWeights
SmartPointer< Self > Pointer
ThreadIdType m_RequestedNumberOfWorkUnits
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
VectorGradientMagnitudeImageFilter Self
static constexpr unsigned int ImageDimension
TRealType NonPCEvaluateAtNeighborhood(const ConstNeighborhoodIteratorType &it) const
Vector< TRealType, InputPixelType::Dimension > RealVectorType
typename InputImageType::Superclass ImageBaseType
FixedArray< TRealType, VectorDimension > ComponentWeightsType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
A templated class holding a n-Dimensional vector.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned int ThreadIdType