ITK  6.0.0
Insight Toolkit
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
itk::SobelOperator< TPixel, VDimension, TAllocator > Class Template Reference

#include <itkSobelOperator.h>

Detailed Description

template<typename TPixel, unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
class itk::SobelOperator< TPixel, VDimension, TAllocator >

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

constexpr auto radius = itk::Size<2>::Filled(1);
sobelOperator.CreateToRadius(radius);
static constexpr Self Filled(const SizeValueType value)
Definition: itkSize.h:425

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 extension to 3D is from the publication "Irwin Sobel. An Isotropic 3x3x3 Volume Gradient Operator. Technical report, Hewlett-Packard Laboratories, April 1995."

The Sobel operator in 3D has the kernel

* -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
* 

The x kernel is just rotated as required to obtain the kernel in the y and z directions.

Note
SobelOperator does not have any user-declared "special member function", following the C++ Rule of Zero: the compiler will generate them if necessary.
See also
NeighborhoodOperator
Neighborhood
ForwardDifferenceOperator
BackwardDifferenceOperator
ITK Sphinx Examples:
  • <a href=
  • <a href=

Definition at line 97 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, 2, NeighborhoodAllocator< TPixel > >
using PixelRealType = typename NumericTraits< TPixel >::RealType
 
using PixelType = TPixel
 
using Self = NeighborhoodOperator
 
using SizeType = itk::Size< VDimension >
 
using SliceIteratorType = SliceIterator< TPixel, Self >
 
using Superclass = Neighborhood< TPixel, VDimension, NeighborhoodAllocator< TPixel > >
 
- Public Types inherited from itk::Neighborhood< TPixel, VDimension, NeighborhoodAllocator< TPixel > >
using AllocatorType = NeighborhoodAllocator< TPixel >
 
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 >
 

Public Member Functions

void CreateDirectional () override
 
const char * GetNameOfClass () const override
 
- Public Member Functions inherited from itk::NeighborhoodOperator< TPixel, 2, NeighborhoodAllocator< TPixel > >
virtual void CreateDirectional ()
 
virtual void CreateToRadius (const SizeType &)
 
virtual void CreateToRadius (const SizeValueType)
 
virtual void FlipAxes ()
 
unsigned long GetDirection () const
 
const char * GetNameOfClass () const override
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void ScaleCoefficients (PixelRealType)
 
void SetDirection (const unsigned long direction)
 
- Public Member Functions inherited from itk::Neighborhood< TPixel, VDimension, NeighborhoodAllocator< TPixel > >
NeighborIndexType GetCenterNeighborhoodIndex () const
 
TPixel GetCenterValue () const
 
virtual const char * GetNameOfClass () const
 
virtual NeighborIndexType GetNeighborhoodIndex (const OffsetType &) const
 
OffsetType GetOffset (NeighborIndexType i) const
 
const SizeType GetRadius () const
 
SizeValueType GetRadius (DimensionValueType n) const
 
SizeType GetSize () const
 
SizeValueType GetSize (DimensionValueType n) const
 
std::slice GetSlice (unsigned int) const
 
OffsetValueType GetStride (DimensionValueType axis) const
 
 ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION (Self)
 
 Neighborhood ()=default
 
 Neighborhood (const Self &)=default
 
 Neighborhood (Self &&)=default
 
Selfoperator= (const Self &)=default
 
Selfoperator= (Self &&)=default
 
bool operator== (const Self &other) const
 
void Print (std::ostream &os) const
 
void SetRadius (const SizeType &)
 
void SetRadius (const SizeValueType)
 
NeighborIndexType Size () const
 
virtual ~Neighborhood ()=default
 
Iterator End ()
 
ConstIterator End () const
 
Iterator Begin ()
 
ConstIterator Begin () const
 
TPixel & operator[] (NeighborIndexType i)
 
const TPixel & operator[] (NeighborIndexType i) const
 
TPixel & GetElement (NeighborIndexType i)
 
TPixel & operator[] (const OffsetType &o)
 
const TPixel & operator[] (const OffsetType &o) const
 
void SetRadius (const SizeValueType *rad)
 
AllocatorTypeGetBufferReference ()
 
const AllocatorTypeGetBufferReference () const
 

Protected Types

using CoefficientVector = typename std::vector< PixelRealType >
 
- Protected Types inherited from itk::NeighborhoodOperator< TPixel, 2, NeighborhoodAllocator< TPixel > >
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, 2, NeighborhoodAllocator< TPixel > >
virtual void Fill (const CoefficientVector &)=0
 
virtual void FillCenteredDirectional (const CoefficientVector &)
 
virtual CoefficientVector GenerateCoefficients ()=0
 
void InitializeToZero ()
 
- Protected Member Functions inherited from itk::Neighborhood< TPixel, VDimension, NeighborhoodAllocator< TPixel > >
virtual void Allocate (NeighborIndexType i)
 
virtual void ComputeNeighborhoodOffsetTable ()
 
virtual void ComputeNeighborhoodStrideTable ()
 
virtual void PrintSelf (std::ostream &, Indent) const
 
void SetSize ()
 

Additional Inherited Members

- Static Public Attributes inherited from itk::Neighborhood< TPixel, VDimension, NeighborhoodAllocator< TPixel > >
static constexpr unsigned int NeighborhoodDimension
 

Member Typedef Documentation

◆ CoefficientVector

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
using itk::NeighborhoodOperator< TPixel, VDimension, TAllocator >::CoefficientVector = typename std::vector<PixelRealType>
protected

Type alias support for coefficient vector type. Necessary to fix bug in the microsoft VC++ compiler.

Definition at line 153 of file itkNeighborhoodOperator.h.

◆ Self

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
using itk::SobelOperator< TPixel, VDimension, TAllocator >::Self = SobelOperator

Standard class type aliases.

Definition at line 102 of file itkSobelOperator.h.

◆ Superclass

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
using itk::SobelOperator< TPixel, VDimension, TAllocator >::Superclass = NeighborhoodOperator<TPixel, VDimension, TAllocator>

Definition at line 103 of file itkSobelOperator.h.

Member Function Documentation

◆ CreateDirectional()

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
void itk::SobelOperator< TPixel, VDimension, TAllocator >::CreateDirectional ( )
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.

See also
CreateToRadius
FillCenteredDirectional
SetDirection()
GetDirection()

Reimplemented from itk::NeighborhoodOperator< TPixel, 2, NeighborhoodAllocator< TPixel > >.

Definition at line 112 of file itkSobelOperator.h.

◆ Fill()

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
void itk::SobelOperator< TPixel, VDimension, TAllocator >::Fill ( const CoefficientVector coeff)
overrideprotectedvirtual

Arranges coefficients spatially in the memory buffer.

Implements itk::NeighborhoodOperator< TPixel, 2, NeighborhoodAllocator< TPixel > >.

◆ GenerateCoefficients()

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
CoefficientVector itk::SobelOperator< TPixel, VDimension, TAllocator >::GenerateCoefficients ( )
overrideprotectedvirtual

Calculates operator coefficients.

Implements itk::NeighborhoodOperator< TPixel, 2, NeighborhoodAllocator< TPixel > >.

◆ GetNameOfClass()

template<typename TPixel , unsigned int VDimension = 2, typename TAllocator = NeighborhoodAllocator<TPixel>>
const char * itk::SobelOperator< TPixel, VDimension, TAllocator >::GetNameOfClass ( ) const
overridevirtual

The documentation for this class was generated from the following file: