是否可以在 MATLAB 中实现以下功能?

Is it possible to implement the following in MATLAB?

根据 I(i, j) = |4-i-j| 给出一张 5x5 的图像当 i,j = 0,1,2,3,4.

和以下 Prewitt 运算符:

               { {-1, 0, 1},
                 {-1, 0, 1},
                 {-1, 0, 1} }

               { {-1, -1, -1},
                 {0, 0, 0},
                 {1, 1, 1} }

如何计算梯度? [大小和方向](使用 Prewitt 算子)

有多种方法可以做到这一点:

  • 自己写卷积函数
  • 使用imgradient
  • 使用imfilter
  • 使用conv2