function [ frame_encoded ] = encode_I_frame( frame_in, B_size, MB_size, Q)


[Y,chroma] = RGB_to_YCbCr(frame_in);

Nmb = size(Y)/MB_size;

Y_mb = mat2cell(Y, repmat(MB_size,1,Nmb(1)), repmat(MB_size,1,Nmb(2)));
Y_encoded = cell(size(Y_mb));

chroma_mb = mat2cell(chroma, repmat(MB_size/2,1,Nmb(1)), repmat(MB_size/2,1,Nmb(2)),2);
chroma_encoded = cell(size(chroma_mb));

for n = 1 : Nmb(1)
    for m = 1 : Nmb(2)

        Y_encoded{n,m} = quantize( Y_mb{n,m}, MB_size, B_size, Q );
        chroma_encoded{n,m} = quantize( chroma_mb{n,m}, MB_size, B_size, Q );

    end
end

Y_encoded = cell2mat(Y_encoded);
chroma_encoded = cell2mat(chroma_encoded);
frame_encoded = struct('encoded_luma',Y_encoded,'encoded_chroma',chroma_encoded);

end

