It seems a good code. But I need reverse of this. I want to write a 4:2:0 YUV file from a sequence of 2D image files (matrix form). Any idea? please help.
Currently the program lacks an example of how to use the code.
e.g. in the file, loadFileYuv.m, the function call is:
function [mov,imgRgb] = loadFileYuv(fileName, width, height, idxFrame)
What is idxFrame? I thought it might be frames per second, but the code seems to indicate it is some sort of structure. Does this mean the YUV video file needs to be loaded into MATLAB as a variable before this subroutine is used?
It seems like this code may work well, but it just needs an example so most people can use it!! Any help would be appreciated.
"idxFrame" is the frame number within the YUV 4:2:0 video you want extracted to an RGB image. Thus, each time you run the function loadFileYuv, it will open the YUV file, extract the specified frame from the video file in the fileName string, and close the YUV file.
I have matlab 7.0.1 and unfortunately i can't find functions for yuv, e.g i want to load yuv file into matlab and i cannot find the appropriate function, help? thank you
Shashi, I believe you are referring to the line
sizeFrame = 1.5 * width * height;
occuring in the file loadFileYuv.m.
The author is preparing enough memory to be able to load one whole YUV (or YCbCr) 4:2:0 frame. This type of video encoding is called "Chroma Subsampling". 4:2:0 means that all luminance values of the scene are recorded, but Cb and Cr are each subsampled at a factor of 2 both horizontally and vertically. This means the total amount of data required to store each frame is:
Total = luminance + Cb + Cr
Total = full resolution + 1/4 res + 1/4 res
Total = 1.5 * full resolution
I am little confused how he's separating Y,U and V components here,because I am not sure how data is saved in a YUV file. when he first uses uses buf = fread(fileId, width * height, 'uchar'); and after reshaping this data he uses fread(fileId,width/2*height/2,'uchar')
that is 1/4 of the data used in previous 'fread' function and because there is no fseek between these 2 fread function and the next fread function the read data should be the same(atleast first 1/4 part of the data read using fread(fileId,height*width,'uchar') and fread(fileID,height/2*width/2,'uchar')).I am also not getting why/how he's using 'kron' to reshape the U and V components.