Create Sobel Kernel

Synopsis

Create the Sobel kernel.

Results

Output:

Neighborhood:
Radius:[1, 1]
Size:[3, 3]
DataBuffer:NeighborhoodAllocator { this = 0x7ffee3e84a00, begin = 0x7fca93256b10, size=9 }
-1
0
1
-2
0
2
-1
0
1

Code

C++

#include <itkSobelOperator.h>

int
main(int, char *[])
{
  using SobelOperatorType = itk::SobelOperator<float, 2>;
  SobelOperatorType sobelOperator;
  sobelOperator.SetDirection(0); // Create the operator for the X axis derivative
  itk::Size<2> radius;
  radius.Fill(1);
  sobelOperator.CreateToRadius(radius);

  std::cout << sobelOperator << std::endl;

  for (unsigned int i = 0; i < 9; i++)
  {
    std::cout << sobelOperator.GetElement(i) << std::endl;
  }
  return EXIT_SUCCESS;
}

Classes demonstrated