Image processing Mathematica中倍频程矩阵函数的转换

Image processing Mathematica中倍频程矩阵函数的转换,image-processing,wolfram-mathematica,octave,Image Processing,Wolfram Mathematica,Octave,我试图解决一个问题:我需要翻译mathematica中的一个八度代码,但我正在努力处理这些行 function g = NeumannBoundCond(f) [nrow,ncol] = size(f); g = f; g([1 nrow],[1 ncol]) = g([3 nrow-2],[3 ncol-2]); g([1 nrow],2:end-1) = g([3 nrow-2],2:end-1); g(2:end-1,[1 ncol]) = g(2:end-1,[3

我试图解决一个问题:我需要翻译mathematica中的一个八度代码,但我正在努力处理这些行

function g = NeumannBoundCond(f)
[nrow,ncol] = size(f);
g = f;
g([1 nrow],[1 ncol]) = g([3 nrow-2],[3 ncol-2]);  
g([1 nrow],2:end-1) = g([3 nrow-2],2:end-1);          
g(2:end-1,[1 ncol]) = g(2:end-1,[3 ncol-2]); 
其中,f的定义如下:

c0=2;
initialLSF = c0*ones(size(Img));
initialLSF(25:35,20:25)=-c0; 
initialLSF(25:35,40:50)=-c0;
f=initialLSF;
Mathematica的等价物是什么? 提前谢谢

附言。 它的相应功能是什么

[Ix,Iy] = gradient[Img];

根据这里的帖子:,第一部分应该这样做:-

NeumannBoundCond[f_] := Module[{g},
   g = f;
   g[[{1, -1}]] = g[[{3, -3}]];
   g[[All, {1, -1}]] = g[[All, {3, -3}]];
   g];

MatrixForm[m = Partition[Range[56], 7]]
MatrixForm@NeumannBoundCond[m]