Hi I have implemented a sliding window over an image in matlab using this code:
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(:));
window(r, c).average=average;
% if mean pixel intensity is greater than 200 then keep the window for
% further inspection. If not then discard the window.
if average<200
imgWindow=false;
end
end
end
figure(2);
imshow(Z);
The aim of this code is to check the mean intensity within each sliding window and if the mean intensity is less than 200 then turn the pixels inside the window black.
However when I try to view the resulting image after the sliding window and travelled the whole image , I just see the orginal image again.
Can anyone please help me with this?