Create Forward Difference Kernel

Synopsis

Create a forward difference kernel.

Results

Output:

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

Code

C++

#include <itkForwardDifferenceOperator.h>

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

  std::cout << "Size: " << forwardDifferenceOperator.GetSize() << std::endl;

  std::cout << forwardDifferenceOperator << std::endl;

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

Classes demonstrated