I need to create a 32x32 sliding window on an image Z. I then need to check the mean intensity of each window on the image.
Can I use: n=[32,32] h = fspecial('average', n); filter2(h, img)
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
However this only creates 12x30. Can anyone spot where I have gone wrong?