generateSobelKernel function

List<List<double>> generateSobelKernel(
  1. String direction
)

Implementation

List<List<double>> generateSobelKernel(String direction) {
  if (direction == 'x') {
    return [
      [-1, 0, 1],
      [-2, 0, 2],
      [-1, 0, 1],
    ];
  } else if (direction == 'y') {
    return [
      [-1, -2, -1],
      [0, 0, 0],
      [1, 2, 1],
    ];
  }
  throw ArgumentError('Invalid direction: $direction');
}