Reputation: 689
I am working on an application that is supposed to work with NV21 YUV format on Android. Just for the purpose of checking what my algorithm does I need to save YUV format to RGB and then to bitmap file to take a look at it. So the algorithm I wrote for this is very simple. The program loads the bitmab RGB image converts it to NV21 and then converts it to RGB and saves to disk. I implemented the conversions given in Wikipedia YUV subject. I am using Full swing for BT.601 for RGB to YUV conversion and Y'UV420sp (NV21) to RGB conversion (Android) for RGB to YUV. However the image loses its colors. I checked my code (which is very simple unoptimized and straightforward) many times and I haven't found any error. Is there something wrong with the conversions I am using?
Input image:
Output image:
Upvotes: 0
Views: 1887
Reputation: 344
Knowing nothing about your code, it is almost impossible to tell something definite.
However, the way the image is corrupted indicates that:
I suggest that you double-check proper handling of U/V pointers when either converting from RGB, or to RGB. Rememer, NV21 is mixed-planar and 4:2:0 subsampled, while generic RGB (esp. if you use it for bitmap import/export) can be either planar or interleaved, but not subsampled.
Also, usually it is much easier to get a comprehensive advice if supply some code showing how do you handle things.
Upvotes: 3