Hi
I try to use a block operation in a image 400x400. It works fine . Now if i use different image this code does not work. So please any one tell me how to add padding zeros using the for loop.
We have a function in matlab, but i want to use in this for loop same thing , please any one tell me how to do that . my code
I = imread('5.jpg');
Block size (bk) = 50;
for j = 1:bk:size(rgb,2)
for i = 1:bk:size(rgb,1)
block = gray(i:(i+(bk-1)), j:(j+(bk-1)));
/// do some operation
end
end
figure,imshow(z);
The above code works fine if the image size is divided by Block size, but if the image size if different , then there is a error like this
??? Index exceeds matrix dimensions.
Error in ==> block_gradient at 12
block = gray(i:(i+(bk-1)), j:(j+(bk-1)));
So please any one help me to fix this . How to add padding inside this loop, so that this will work for all image.
Thank You