I am using this code to read YUV420 and convert to RGB. Because I have YUV420.YUV image file but that code is for video therefore, I only read 1frame. Then I get YUV as Y as the full size but U and V as half size as described at wikiepdia. I then resze the images to the full size of the image and apply YUV to RGB coversion. But the RGB images are not in correct colours. I have attached the files so that you can run and see what is the problem. Here is the YUV filetulips_yuv420_inter_planar_qcif.yuv
I have two more questions;
Firstly, The size of the "stream" for one frame should be equal to 1.5*the size of the Y but it is very large whether I use uint8 or uint16 to read the file.
Secondly, If I have 10bit YUV420 file how to I to modify this code to show correct RGB.
fname = 'tulips_yuv420_inter_planar_qcif.yuv';
width = 176;
height = 144;
fid = fopen(fname,'r');
stream = fread(fid);
length = 1.5 * width * height;
The full code is attached kindly help to sort out the issue.