本文详细介绍了如何使用MATLAB进行读写YUV文件,并给出了详细的代码及其分析。
示例程序如下:
close all;
clear;
fid1=fopen('D:\HM-14.0-ROI\bin\vc10\Win32\Release\Result\背景建模Result\hall_cif_352x288_300\QP=22\bgf_rec.yuv','rb');
fid2=fopen('D:\HM-14.0-ROI\bin\vc10\Win32\Release\Result\背景建模Result\hall_cif_352x288_300\QP=22\cal_rec.yuv','rb');
outfid=fopen('D:\HM-14.0-ROI\bin\vc10\Win32\Release\Result\背景建模Result\hall_cif_352x288_300\QP=22\com_rec.yuv','wb');
%fseek(fid,352*288*1.5*10,'bof');
fseek(fid1,0,'bof');
fseek(fid2,0,'bof');
Y_bgf=fread(fid1,[352,288],'uint8');
for j=1:300
Y_cal=fread(fid2,[352,288],'uint8');
Cb_cal=fread(fid2,[352/2,288/2],'uint8');
Cr_cal=fread(fid2,[352/2,288/2],'uint8');
for x=1:352