i am trying to split an image into blocks 16x16 here is my code
A = imread('telec.jpg'); %reads file into a matrix
B = rgb2ycbcr(A); %reads file info
%convert to YCbCr
%if B.Format=='bmp'
% A=rgb2ycbcr(A)
[width height]=size(B);
%detirmine number of 8x8 matrices, use ceil to round up
W=ceil(width/8);
H=ceil(height/8);
%create a matrix of zeros and add the image to it to fill out the 8x8
%matrices (matrix will stay the same size if height and width are
%divisible by 8
I=zeros(H*8,W*8,'uint8');
I(1:height,1:width)=B(1:height,1:width);
%divide numbers into WxH 8x8 matrices
X=zeros(H,W,8,8);
for J=1:H
for K=1:W
for j=1:8
for k=1:8
X(J,K,j,k)=I((J-1)*8+j,(K-1)*8+k);
end
end
end
end
i get this:
??? Index exceeds matrix dimensions.
Error in ==> projet at 18
I(1:height,1:width)=B(1:height,1:width); can anyone help?thanks in advance