From .ppm image, I extracted R,G,B data and saved following structures:
RGB RGB RGB RGB RGB RGB RGB..........
corresponding to each pixel position.
Then I used formula to convert R,G,V into Y,U,V.With each pixel, I obtained YUV correspondingly.
R0G0B0->Y0U0V0 , R1G1B1 ->Y1U1B1, ........
I saved data following YUV422 Data Format:The YUV422 data format shares U and V values between two pixels. As a result, these values are transmitted to the PC image buffer only once for every two pixels.
R0G0B0R1G1B1->Y0UY1V
a,How to calculate U and V from U0,U1 and V0,V1????????
b,In my case , I used this formula:
U=(U0+U1)/2; V=(V0+V1)/2;
Obtained data was saved following structure to create .yuv file:
YUYV YUYV YUYV YUYV YUYV YUYV......
But when I used YUV tools to read new .yuv file, that image is not similar to original image. What did I do wrong here ????