#include <itkSobelOperator.h>
A NeighborhoodOperator for performing a directional Sobel edge-detection operation at a pixel location.
SobelOperator is a directional NeighborhoodOperator that should be applied a NeighborhoodIterator using the NeighborhoodInnerProduct method. To create the operator:
1) Set the direction by calling
2) call
3) You may optionally scale the coefficients of this operator using the
method. This is useful if you want to take the spacing of the image into account when computing the edge strength. Apply the scaling only after calling to
.
The Sobel Operator in vertical direction for 2 dimensions is
* -1 -2 -1 * 0 0 0 * 1 2 1 * *
The Sobel Operator in horizontal direction is for 2 dimensions is
* -1 0 1 * -2 0 2 * -1 0 1 *
The current implementation of the Sobel operator is for 2 and 3 dimensions only. The ND version is planned for future releases.
The Sobel operator in 3D has the following kernel, when using legacy coefficients:
* -1 -3 -1 0 0 0 1 3 1 * -3 -6 -3 0 0 0 3 6 3 * -1 -3 -1 0 0 0 1 3 1 * * x-1 x x+1 *
And it has the following kernel, when it is not using legacy coefficients:
* -1 -2 -1 0 0 0 1 2 1 * -2 -4 -2 0 0 0 2 4 2 * -1 -2 -1 0 0 0 1 2 1 * * x-1 x x+1 *
The x kernel is just rotated as required to obtain the kernel in the y and z directions.
Definition at line 103 of file itkSobelOperator.h.
Inheritance diagram for itk::SobelOperator< TPixel, VDimension, TAllocator >:
Collaboration diagram for itk::SobelOperator< TPixel, VDimension, TAllocator >:Public Types | |
| using | Self = SobelOperator |
| using | Superclass = NeighborhoodOperator<TPixel, VDimension, TAllocator> |
Public Types inherited from itk::NeighborhoodOperator< TPixel, VDimension, TAllocator > | |
| using | PixelRealType = typename NumericTraits<TPixel>::RealType |
| using | PixelType = TPixel |
| using | Self = NeighborhoodOperator |
| using | SliceIteratorType = SliceIterator<TPixel, Self> |
| using | Superclass = Neighborhood<TPixel, VDimension, TAllocator> |
Public Types inherited from itk::Neighborhood< TPixel, VDimension, TAllocator > | |
| using | AllocatorType = TAllocator |
| using | ConstIterator = typename AllocatorType::const_iterator |
| using | DimensionValueType = unsigned int |
| using | Iterator = typename AllocatorType::iterator |
| using | NeighborIndexType = SizeValueType |
| using | OffsetType = Offset<VDimension> |
| using | PixelType = TPixel |
| using | RadiusType = itk::Size<VDimension> |
| using | Self = Neighborhood |
| using | SizeType = itk::Size<VDimension> |
| using | SizeValueType = typename SizeType::SizeValueType |
| using | SliceIteratorType = SliceIterator<TPixel, Self> |
Protected Types | |
| using | CoefficientVector |
Protected Types inherited from itk::NeighborhoodOperator< TPixel, VDimension, TAllocator > | |
| using | CoefficientVector = typename std::vector<PixelRealType> |
Protected Member Functions | |
| void | Fill (const CoefficientVector &coeff) override |
| CoefficientVector | GenerateCoefficients () override |
Protected Member Functions inherited from itk::NeighborhoodOperator< TPixel, VDimension, TAllocator > | |
| virtual void | FillCenteredDirectional (const CoefficientVector &) |
| void | InitializeToZero () |
Protected Member Functions inherited from itk::Neighborhood< TPixel, VDimension, TAllocator > | |
| virtual void | Allocate (NeighborIndexType i) |
| virtual void | ComputeNeighborhoodOffsetTable () |
| virtual void | ComputeNeighborhoodStrideTable () |
| void | SetSize () |
Private Attributes | |
| bool | m_UseLegacyCoefficients { true } |
Additional Inherited Members | |
Static Public Attributes inherited from itk::Neighborhood< TPixel, VDimension, TAllocator > | |
| static constexpr unsigned int | NeighborhoodDimension = VDimension |
|
protected |
Type alias support for coefficient vector type. Necessary to fix bug in the microsoft VC++ compiler.
Definition at line 152 of file itkNeighborhoodOperator.h.
| using itk::SobelOperator< TPixel, VDimension, TAllocator >::Self = SobelOperator |
Standard class type aliases.
Definition at line 107 of file itkSobelOperator.h.
| using itk::SobelOperator< TPixel, VDimension, TAllocator >::Superclass = NeighborhoodOperator<TPixel, VDimension, TAllocator> |
Definition at line 108 of file itkSobelOperator.h.
|
inlineoverridevirtual |
Creates the operator with length only in the specified direction. The radius of the operator will be 0 except along the axis on which the operator will work.
Reimplemented from itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >.
Definition at line 120 of file itkSobelOperator.h.
References itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >::CreateToRadius().
|
overrideprotectedvirtual |
Arranges coefficients spatially in the memory buffer.
Implements itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >.
|
overrideprotectedvirtual |
Calculates operator coefficients.
Implements itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >.
|
virtual |
Reimplemented from itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >.
|
inline |
Tells whether or not GenerateCoefficients() returns the legacy coordinate values, compatible with ITK <= 5.4.
Definition at line 141 of file itkSobelOperator.h.
References m_UseLegacyCoefficients.
|
inline |
Creates the operator with a specified radius ("square", same length on each side). The spatial location of the coefficients within the operator is defined by the subclass implementation of the Fill method.
GenerateCoefficients() should return the legacy coordinate values, compatible with ITK <= 5.4. Definition at line 134 of file itkSobelOperator.h.
References m_UseLegacyCoefficients.
|
private |
Definition at line 161 of file itkSobelOperator.h.
Referenced by IsUsingLegacyCoefficients(), and UseLegacyCoefficients().