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);
217 itkGetConstMacro(UseImageSpacing,
bool);
224 itkGetConstReferenceMacro(DerivativeWeights,
WeightsType);
230 itkGetConstReferenceMacro(ComponentWeights,
WeightsType);
234 itkGetConstReferenceMacro(NeighborhoodRadius,
RadiusType);
243 itkSetMacro(UsePrincipleComponents,
bool);
244 itkGetConstMacro(UsePrincipleComponents,
bool);
260 #ifdef ITK_USE_CONCEPT_CHECKING
302 TRealType dx, sum, accum;
316 return vcl_sqrt(accum);
328 vnl_vector_fixed< TRealType, VectorDimension >
329 d_phi_du[TInputImage::ImageDimension];
347 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
354 CharEqn[2] = -( g[0][0] + g[1][1] + g[2][2] );
356 CharEqn[1] = ( g[0][0] * g[1][1] + g[0][0] * g[2][2] + g[1][1] * g[2][2] )
357 - ( g[0][1] * g[1][0] + g[0][2] * g[2][0] + g[1][2] * g[2][1] );
359 CharEqn[0] = g[0][0] * ( g[1][2] * g[2][1] - g[1][1] * g[2][2] )
360 + g[1][0] * ( g[2][2] * g[0][1] - g[0][2] * g[2][1] )
361 + g[2][0] * ( g[1][1] * g[0][2] - g[0][1] * g[1][2] );
364 int numberOfDistinctRoots = this->
CubicSolver(CharEqn, Lambda);
368 if ( numberOfDistinctRoots == 3 )
370 if ( Lambda[0] > Lambda[1] )
372 if ( Lambda[1] > Lambda[2] )
374 ans = Lambda[0] - Lambda[1];
378 if ( Lambda[0] > Lambda[2] )
380 ans = Lambda[0] - Lambda[2];
384 ans = Lambda[2] - Lambda[0];
390 if ( Lambda[0] > Lambda[2] )
392 ans = Lambda[1] - Lambda[0];
396 if ( Lambda[1] > Lambda[2] )
398 ans = Lambda[1] - Lambda[2];
402 ans = Lambda[2] - Lambda[1];
407 else if ( numberOfDistinctRoots == 2 )
409 if ( Lambda[0] > Lambda[1] )
411 ans = Lambda[0] - Lambda[1];
415 ans = Lambda[1] - Lambda[0];
418 else if ( numberOfDistinctRoots == 1 )
424 itkExceptionMacro(<<
"Undefined condition. Cubic root solver returned "
425 << numberOfDistinctRoots <<
" distinct roots.");
439 vnl_vector_fixed< TRealType, VectorDimension >
440 d_phi_du[TInputImage::ImageDimension];
458 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
463 vnl_symmetric_eigensystem< TRealType > E(g);
467 return ( E.get_eigenvalue(ImageDimension - 1) - E.get_eigenvalue(ImageDimension - 2) );
494 #ifndef ITK_MANUAL_INSTANTIATION
495 #include "itkVectorGradientMagnitudeImageFilter.hxx"
WeightsType m_SqrtComponentWeights
virtual void GenerateInputRequestedRegion()
WeightsType m_ComponentWeights
ConstNeighborhoodIterator< RealVectorImageType > ConstNeighborhoodIteratorType
bool m_UsePrincipleComponents
void SetUsePrincipleComponentsOn()
FixedArray< TRealType, VectorDimension > WeightsType
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
WeightsType m_DerivativeWeights
ImageBaseType::ConstPointer m_RealValuedInputImage
TRealType EvaluateAtNeighborhood3D(const ConstNeighborhoodIteratorType &it) const
SmartPointer< const Self > ConstPointer
virtual void SetUsePrincipleComponents(bool _arg)
TOutputImage OutputImageType
TInputImage InputImageType
SmartPointer< Self > Pointer
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()
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
TRealType NonPCEvaluateAtNeighborhood(const ConstNeighborhoodIteratorType &it) const
void operator=(const Self &)
static const unsigned int VectorDimension
void SetUseImageSpacingOff()
RadiusType m_NeighborhoodRadius
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.
void BeforeThreadedGenerateData()
Superclass::OutputImageRegionType OutputImageRegionType
Define additional traits for native types such as int or float.
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
unsigned int ThreadIdType
void PrintSelf(std::ostream &os, Indent indent) const
void SetUseImageSpacingOn()