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"
28 #include "vnl/vnl_math.h"
134 template<
typename TInputImage,
135 typename TRealType = float,
136 typename TOutputImage = Image< TRealType,
137 TInputImage::ImageDimension >
168 TOutputImage::ImageDimension);
172 InputPixelType::Dimension);
216 itkGetConstMacro(UseImageSpacing,
bool);
223 itkGetConstReferenceMacro(DerivativeWeights,
WeightsType);
229 itkGetConstReferenceMacro(ComponentWeights,
WeightsType);
232 #ifndef ITK_LEGACY_REMOVE
234 virtual const RadiusType GetNeighborhoodRadius()
const
243 virtual void SetNeighborhoodRadius(
const RadiusType) {}
251 itkSetMacro(UsePrincipleComponents,
bool);
252 itkGetConstMacro(UsePrincipleComponents,
bool);
268 #ifdef ITK_USE_CONCEPT_CHECKING
305 itkGetConstObjectMacro(RealValuedInputImage, ImageBaseType);
310 TRealType dx, sum, accum;
319 * 0.5 * ( it.GetNext(i)[j] - it.GetPrevious(i)[j] );
324 return std::sqrt(accum);
336 vnl_vector_fixed< TRealType, VectorDimension >
337 d_phi_du[TInputImage::ImageDimension];
355 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
362 CharEqn[2] = -( g[0][0] + g[1][1] + g[2][2] );
364 CharEqn[1] = ( g[0][0] * g[1][1] + g[0][0] * g[2][2] + g[1][1] * g[2][2] )
365 - ( g[0][1] * g[1][0] + g[0][2] * g[2][0] + g[1][2] * g[2][1] );
367 CharEqn[0] = g[0][0] * ( g[1][2] * g[2][1] - g[1][1] * g[2][2] )
368 + g[1][0] * ( g[2][2] * g[0][1] - g[0][2] * g[2][1] )
369 + g[2][0] * ( g[1][1] * g[0][2] - g[0][1] * g[1][2] );
372 int numberOfDistinctRoots = this->
CubicSolver(CharEqn, Lambda);
376 if ( numberOfDistinctRoots == 3 )
378 if ( Lambda[0] > Lambda[1] )
380 if ( Lambda[1] > Lambda[2] )
382 ans = Lambda[0] - Lambda[1];
386 if ( Lambda[0] > Lambda[2] )
388 ans = Lambda[0] - Lambda[2];
392 ans = Lambda[2] - Lambda[0];
398 if ( Lambda[0] > Lambda[2] )
400 ans = Lambda[1] - Lambda[0];
404 if ( Lambda[1] > Lambda[2] )
406 ans = Lambda[1] - Lambda[2];
410 ans = Lambda[2] - Lambda[1];
415 else if ( numberOfDistinctRoots == 2 )
417 if ( Lambda[0] > Lambda[1] )
419 ans = Lambda[0] - Lambda[1];
423 ans = Lambda[1] - Lambda[0];
426 else if ( numberOfDistinctRoots == 1 )
432 itkExceptionMacro(<<
"Undefined condition. Cubic root solver returned "
433 << numberOfDistinctRoots <<
" distinct roots.");
447 vnl_vector_fixed< TRealType, VectorDimension >
448 d_phi_du[TInputImage::ImageDimension];
466 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
471 vnl_symmetric_eigensystem< TRealType > E(g);
475 return ( E.get_eigenvalue(ImageDimension - 1) - E.get_eigenvalue(ImageDimension - 2) );
496 void operator=(const
Self &) ITK_DELETE_FUNCTION;
500 #ifndef ITK_MANUAL_INSTANTIATION
501 #include "itkVectorGradientMagnitudeImageFilter.hxx"
WeightsType m_SqrtComponentWeights
WeightsType m_ComponentWeights
ConstNeighborhoodIterator< RealVectorImageType > ConstNeighborhoodIteratorType
bool m_UsePrincipleComponents
void PrintSelf(std::ostream &os, Indent indent) const override
void SetUsePrincipleComponentsOn()
FixedArray< TRealType, VectorDimension > WeightsType
WeightsType m_DerivativeWeights
ImageBaseType::ConstPointer m_RealValuedInputImage
virtual void GenerateInputRequestedRegion() override
TRealType EvaluateAtNeighborhood3D(const ConstNeighborhoodIteratorType &it) const
SmartPointer< const Self > ConstPointer
virtual void SetUsePrincipleComponents(bool _arg)
TOutputImage OutputImageType
TInputImage InputImageType
SmartPointer< Self > Pointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
ImageToImageFilter< TInputImage, TOutputImage > Superclass
Superclass::OutputImageRegionType OutputImageRegionType
Superclass::RadiusType RadiusType
Base class for all process objects that output image data.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
ConstNeighborhoodIteratorType::RadiusType RadiusType
virtual PixelType GetPrevious(const unsigned axis, NeighborIndexType i) const
Computes a scalar, gradient magnitude image from a multiple channel (pixels are vectors) input...
virtual PixelType GetNext(const unsigned axis, NeighborIndexType i) const
TOutputImage::PixelType OutputPixelType
InputImageType::Pointer InputImagePointer
VectorGradientMagnitudeImageFilter Self
VectorGradientMagnitudeImageFilter()
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
typedef(Concept::HasNumericTraits< typename InputPixelType::ValueType >) InputHasNumericTraitsCheck
OutputImageType::Pointer OutputImagePointer
A templated class holding a n-Dimensional vector.
static const unsigned int ImageDimension
TInputImage::PixelType InputPixelType
static int CubicSolver(double *, double *)
Vector< TRealType, InputPixelType::Dimension > RealVectorType
TInputImage InputImageType
TRealType NonPCEvaluateAtNeighborhood(const ConstNeighborhoodIteratorType &it) const
void BeforeThreadedGenerateData() override
unsigned int ThreadIdType
static const unsigned int VectorDimension
void SetUseImageSpacingOff()
void SetUseImageSpacing(bool)
void SetUsePrincipleComponentsOff()
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Superclass::OutputImageRegionType OutputImageRegionType
virtual ~VectorGradientMagnitudeImageFilter()
#define itkConceptMacro(name, concept)
InputImageType::Superclass ImageBaseType
ThreadIdType m_RequestedNumberOfThreads
Image< RealVectorType, TInputImage::ImageDimension > RealVectorImageType
Templated n-dimensional image class.
TRealType EvaluateAtNeighborhood(const ConstNeighborhoodIteratorType &it) const
void SetUseImageSpacingOn()