我需要在图像Z上创建一个32x32的滑动窗口。然后我需要检查图像上每个窗口的平均强度。在matlab图像上滑动窗口
我可以使用: n = [32,32] h = fspecial('average',n); 过滤器2(H,张图片)
N = 32;
info = repmat(struct, ceil(size(Z, 1)/N), ceil(size(Z, 2)/N));
for row = 1:N:size(Z, 1)%loop through each pixel in the image matrix
for col = 1:N:size(Z, 2)
r = (row - 1)/N + 1;
c = (col - 1)/N + 1;
imgWindow = Z(row:min(end,row+N-1), col:min(end,col+N-1));
average = mean(imgWindow(:)) %calculate the mean intensity of pixels within each window
end
end
然而,这仅创建12X30。任何人都可以发现我出错的地方吗?
与'repmat'一起做的那个魔术字'struct'是什么?它可能无法解决手头的问题,但对此感到好奇。 – Divakar
如果你输入'size(Z)',你会得到什么? – tashuhka
如果您有图像处理工具箱,您可能需要使用它具有的现成滑动过滤器功能。 –