% qcif_y_read.m % ENEE631 Fall 2001 motion estimation and compensation % read qcif file and display YUV % 11/02/2001 % by Guan-Ming Su clear all; close all; % parameters filename='fm10.qcif'; frames=10; col=176; row=144; UV_ratio=2; UV_col=col/UV_ratio; UV_row=row/UV_ratio; Y=zeros(row,col,frames); % open file Y_size=col*row; U_size=UV_col*UV_row; V_size=UV_col*UV_row; buffer_size=Y_size+U_size+V_size; [fid,message]=fopen(filename,'r'); for ith_frame=1:1:frames [raw_YUV,count]=fread(fid,buffer_size,'uint8'); temp_Y_frame=reshape(uint8(raw_YUV(1:Y_size)),[col row])'; temp_U_frame=reshape(uint8(raw_YUV(Y_size+1:Y_size+U_size)),[UV_col UV_row])'; temp_V_frame=reshape(uint8(raw_YUV(Y_size+U_size+1:Y_size+U_size+V_size)),[UV_col UV_row])'; subplot(3,1,1); imshow(temp_Y_frame,[0 255]); title('Y'); subplot(3,1,2); imshow(temp_U_frame,[0 255]); title('U'); subplot(3,1,3); imshow(temp_V_frame,[0 255]); title('V'); xlabel(strcat(num2str(ith_frame),'th frame. Press any key to show next')); pause end status=fclose(fid);