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);
233 itkGetConstReferenceMacro(NeighborhoodRadius,
RadiusType);
242 itkSetMacro(UsePrincipleComponents,
bool);
243 itkGetConstMacro(UsePrincipleComponents,
bool);
259 #ifdef ITK_USE_CONCEPT_CHECKING
296 itkGetConstObjectMacro(RealValuedInputImage, ImageBaseType);
301 TRealType dx, sum, accum;
310 * 0.5 * ( it.GetNext(i)[j] - it.GetPrevious(i)[j] );
315 return std::sqrt(accum);
327 vnl_vector_fixed< TRealType, VectorDimension >
328 d_phi_du[TInputImage::ImageDimension];
346 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
353 CharEqn[2] = -( g[0][0] + g[1][1] + g[2][2] );
355 CharEqn[1] = ( g[0][0] * g[1][1] + g[0][0] * g[2][2] + g[1][1] * g[2][2] )
356 - ( g[0][1] * g[1][0] + g[0][2] * g[2][0] + g[1][2] * g[2][1] );
358 CharEqn[0] = g[0][0] * ( g[1][2] * g[2][1] - g[1][1] * g[2][2] )
359 + g[1][0] * ( g[2][2] * g[0][1] - g[0][2] * g[2][1] )
360 + g[2][0] * ( g[1][1] * g[0][2] - g[0][1] * g[1][2] );
363 int numberOfDistinctRoots = this->
CubicSolver(CharEqn, Lambda);
367 if ( numberOfDistinctRoots == 3 )
369 if ( Lambda[0] > Lambda[1] )
371 if ( Lambda[1] > Lambda[2] )
373 ans = Lambda[0] - Lambda[1];
377 if ( Lambda[0] > Lambda[2] )
379 ans = Lambda[0] - Lambda[2];
383 ans = Lambda[2] - Lambda[0];
389 if ( Lambda[0] > Lambda[2] )
391 ans = Lambda[1] - Lambda[0];
395 if ( Lambda[1] > Lambda[2] )
397 ans = Lambda[1] - Lambda[2];
401 ans = Lambda[2] - Lambda[1];
406 else if ( numberOfDistinctRoots == 2 )
408 if ( Lambda[0] > Lambda[1] )
410 ans = Lambda[0] - Lambda[1];
414 ans = Lambda[1] - Lambda[0];
417 else if ( numberOfDistinctRoots == 1 )
423 itkExceptionMacro(<<
"Undefined condition. Cubic root solver returned "
424 << numberOfDistinctRoots <<
" distinct roots.");
438 vnl_vector_fixed< TRealType, VectorDimension >
439 d_phi_du[TInputImage::ImageDimension];
457 g[j][i] = g[i][j] = dot_product(d_phi_du[i], d_phi_du[j]);
462 vnl_symmetric_eigensystem< TRealType > E(g);
466 return ( E.get_eigenvalue(ImageDimension - 1) - E.get_eigenvalue(ImageDimension - 2) );
493 #ifndef ITK_MANUAL_INSTANTIATION
494 #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
void operator=(const Self &)
unsigned int ThreadIdType
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.
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()