I have data set from images and each image dim is 240x180 , I want to make some processes on each image but after dividing each image into sub-images (blocks) and each block must have this size 20x20 so I should have 108 blocks from each image and I wrote this code but I don't know why the size of result only contain 84 blocks from the original image , it must 108 blocks and the conditions inside loop is correctly .
Img=imread('imagefile.extension'); % read image 240x180
[r c]=size(Img); % r=180 , c=240
bs=20; % Each Block Size (20x20)
nob=(r/bs)*(c/bs); %The total number of 20x20 Blocks = 108
% Dividing the image into 20x20 Blocks
BNo=0;
for i=1:(r/bs)
for j=1:(c/bs)
Block(:,:,BNo+j)=Img((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs));
end
BNo=BNo+(r/bs);
end