在计算 y 方向而不是 x 方向的像素之间的距离时,我遇到了一个愚蠢的错误。这应该更清楚:
% Distance matrix
for pxRow = 1:h % fixed pixel row
for pxCol = 1:w % fixed pixel column
for r = 1:h % row of distant pixel
for c = 1:w % column of distant pixel
Rx(c,r) = sqrt((r-pxRow)^2); % get distance to each pixel x direction
Ry(c,r) = sqrt((c-pxCol)^2); % get distance to each pixel y direction
end
end
Rix(i) = {Rnx};
Riy(i) = {Rny};
i = i+1;
end
end
Rix = reshape(Rix, w, h);
Riy = reshape(Riy, w, h);
在哪里
Rix =
NaN 1.000 0.500 0.333
NaN 1.000 0.500 0.333
NaN 1.000 0.500 0.333
这是正确的,但是
Riy =
NaN NaN NaN NaN
1.000 1.000 1.000 1.000
1.000 1.000 1.000 1.000
这是不正确的,因为我希望 Riy 只是 Rix 的轮换。
这里的错误在哪里?
提前致谢。