I have an M×N image that should be divided into non-overlapping blocks of [3 3]
. For each block I should make the gradient vector, have the mean
of them and finally normalize.
I have resized the image to a dividable dimension by [3 3]
and used blockproc
but when I tested like
fun = @(block_struct) mean2(block_struct.data);
A = blockproc(im,[3 3],fun);
I saw that the block isn't applied to the whole image, but to the top left side of image.
Note: The number of blocks is not known.
[x,y]=size(im)
r=floor(x/3)
c=floor(y/3)
ext_x = mod(x,3);
ext_y = mod(y,3);
a = im(1:(end-ext_x), 1:(end-ext_y));
f= @(block_struct) gradient(block_struct.blockSize);
b=blockproc(im,[3,3],f);
imshow(b)
Any ideas?