Create A Backward Difference Operator

Synopsis

Create a backward difference operator

Results

Output:

Size: [3, 3]
Neighborhood:
    Radius:[1, 1]
    Size:[3, 3]
    DataBuffer:NeighborhoodAllocator { this = 0x7fffb3cae9f8, begin = 0x1dd0e50, size=9 }

[-1, -1] 0
[0, -1] 0
[1, -1] 0
[-1, 0] -1
[0, 0] 1
[1, 0] 0
[-1, 1] 0
[0, 1] 0
[1, 1] 0

Code

C++

#include <itkBackwardDifferenceOperator.h>

int
main(int, char *[])
{
  using PixelType = float;
  constexpr unsigned int Dimension = 2;

  using BackwardDifferenceOperatorType = itk::BackwardDifferenceOperator<PixelType, Dimension>;
  BackwardDifferenceOperatorType backwardDifferenceOperator;

  // Create the operator for the X axis derivative
  backwardDifferenceOperator.SetDirection(0);

  itk::Size<Dimension> radius;
  radius.Fill(1);

  backwardDifferenceOperator.CreateToRadius(radius);

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

  std::cout << backwardDifferenceOperator << std::endl;

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

Classes demonstrated