I need to split an image in windows of 32x32 in matlab.
I then need to get the average intensity value of images within that window and just display it. I do not need to apply a mean filter to the image.
Here is my algorithm:
Split image into window sizes of 32x32
if mean intensity of pixels in 32x32window > 200
split 32x32 window into 8x8 windows.
end
This is what I have tried:
kernel = ones(32)/32^2; % Create averaging window.
output = conv2(grayImage, kernel, 'same'); % Get means
mean=mean(mean(output);
display (mean)
However this just applies a filter to my image. Also tried this:
window_size = 16;
wsz = window_size-1;
mp = round(window_size/2);
img = rgb2gray(input_image); %%// Gray level values
x1 = zeros(size(img)); %%// Row values for the maximum pixel in the 16x16 window
y1 = zeros(size(img)); %%// Column values for the maximum pixel in the 16x16 window
img1 = img;
for k1= 1:size(img,1)-wsz
for k2= 1:size(img,2)-wsz
window_data = img(k1:k1+wsz,k2:k2+wsz);
val = round(mean(window_data(:)));
display(val);
end
end
But this code returns 0 for the average intensity of each window.
Can anyone please suggest a way of doing this?