Lines 20 to 39 in yuv2bmp.m read
[Y,U,V]=yuvread(filename,start_frame,num_frame);%4:2:0%%%%%%%%%%%%%%%%
[My Ny iL]=size(Y);
[Mu Nu iu]=size(U);
[Mv Nv iv]=size(V);
for f=1:num_frame
UU(:,:,f)= imresize(U(:,:,f),[My Ny],'nearest');
VV(:,:,f)= imresize(V(:,:,f),[My Ny],'nearest');
image(:,:,1) = Y(:,:,f)+1.402*(VV(:,:,f)-128);
image(:,:,2) = Y(:,:,f)-0.34414*(UU(:,:,f)-128)-0.71414*(VV(:,:,f)-128);
image(:,:,3) = Y(:,:,f)+1.772*(UU(:,:,f)-128);
fname=sprintf('%s%d%s',filename(1:length(filename)-4),f,'.bmp');
imwrite(uint8(image),fname,'bmp');
end
This looks like it's wasting quite a bit of memory. Unfortunately, I do not have any example yuv images, but try to modify this part of the code the following way, and check whether it still gives you the correct results:
for f=1:num_frame
% read each image of the sequence separately
[Y,U,V]=yuvread(filename,start_frame+f-1,1);%4:2:0%%%%%%%%%%%%%%%%
% in the following three lines, I have replaced UU with U and VV with V, and I've
% removed all the (:,:,f)
image(:,:,1) = Y+1.402*(V-128);
image(:,:,2) = Y-0.34414*(U-128)-0.71414*(V-128);
image(:,:,3) = Y+1.772*(U-128);
fname=sprintf('%s%d%s',filename(1:length(filename)-4),f,'.bmp');
imwrite(uint8(image),fname,'bmp');
end
Also, in lines 52 to 54 of yuvread.m, you can replace 'double' with 'single'. This shaves another 50% off your memory usage, and it should not make any difference to the output, since you are re-casting as uint8 in the end, anyway.