Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6704 Discussions

Not so good colors while doing YUV420 to RGB conversion

vucetica
Beginner
901 Views
Hi,
we are usingippiYUV420ToBGR_8u_P3C3R to convert directshow media sample received from mpeg4 video to RGB image. That RGB image is then saved to AVI. Unfortunately, when I play that AVI in any other player, image is a bit "yellowish". When I convert it back with IPP function (ippiBGRToYUV420_8u...) it looks good. I think that ipp conversion works excellent, but it expects YUV420 to be in some other format than it is. I have read that there are two variants of YUV420: with range 16-235 and range 0-255...obviously IPP assumes different range than color space convertors in video players. Is there any way to overcome this problem. I have attached images where this problem can be seen (not the same sample, even not the same size, but you can notice the difference). Thanks!
Original image
converted
0 Kudos
11 Replies
Tamer_Assad
Innovator
901 Views

Hi vucetica,

YUV color format conversions standards follows certain mathematical formulas; similar to YUV color space is the YCbCr color space, if this is the case, IPP covers YCbCr conversions as well.

Another possibility is the target RGB image, is it RGB24 or RGB32 that your AVI encoder using? make sure you are calling the IPP function that correctly produce your target RGB format.

Regards,
Tamer Assad

0 Kudos
Ying_H_Intel
Employee
901 Views

Hi Vucetica,

Yes, you may tryippiYCbCr420ToBGR_8u_P3C3R and see if there is change.

Tamer, thanks a lot for thesuggestion.

Regards,
Ying

P.s the IPP UMCsample audio-video-codecs\codec\color_space_converter\umc_color_space_conversion.cpp use it as well


switch (srcFormat) {
case YUV420:
switch (dstFormat) {
case RGB24:
status = ippiYCbCr420ToBGR_8u_P3C3R(pSrc, pSrcStep, pDst[0], pDstStep[0], srcSize);

0 Kudos
vucetica
Beginner
901 Views
Guys, thanks for the responses. Unfortunately, ippiYCbCr420ToBGR_8u_P3C3R also gives different colors, but just in "different direction". Please, take a look at the given examples:
Original:
Converted:
Thanks!
Aleksandar
0 Kudos
Tamer_Assad
Innovator
901 Views

Hi Aleksandar,

Would you post an original YUV photo as well as its converted RGB alias, it will help visualizing your problem.

Are you passing BGR or RGB to the AVI encoder as it expects?

Regards,
Tamer

0 Kudos
Tamer_Assad
Innovator
901 Views

also, are you sure of the source photo format? is it YUV420(iYUV) or is YV12?

I strongly doubt that this is what it is about.

0 Kudos
vucetica
Beginner
901 Views
Thanks Tamer,

I can not post image, since it is actually a video sample pushed from a Microsoft DTV-DVD decoder. It is possible that it is YV12 format, though...I can not try it now (environment is on my computer at work)...What should be done if format is YV12 indeed? Does IPP have support for YV12->RGB24? (I'm sure about RGB format...changes in RGB->BGR make a lot of difference). I really appreciate your help on this one.
Aleksandar
0 Kudos
Tamer_Assad
Innovator
901 Views

Hi Aleksandar,

If your source is DirectShow MEDIASUBTYPE_YV12, then you just need to change the order or the pSrc[3] plans, by placing the Cb/U plan into pSrc[2], and Cr/V into pSrc[1].

Resolution:

YV12 is just like YUV420, it just differs in the order of U and V plans

YUV420 sequence: Y->U->V

YV12 sequence: Y-V->U

Regards,

Tamer Assad

0 Kudos
vucetica
Beginner
901 Views
Thanks Tamer.

Will try it out on Tuesday (back to work) and will be back with results. Still, do you think that there is a chance that something is wrong inside IPP functions interpreting differently YUV420 range (16-235 instead 0-255 or vice versa)?
Regards
Aleksandar
0 Kudos
Tamer_Assad
Innovator
901 Views

Hi Aleksandar,

I hope that solution works out for you.

IPP library is pretty well engineered; it has one of the best image and color processing libraries, trust it.

You may want to check the following references:

IPP manual: IPP Image and Video Processing->Image Color Conversion->Color Model Conversion->RGBToYUV

http://fourcc.org/

http://en.wikipedia.org/wiki/YCbCr

http://en.wikipedia.org/wiki/YUV


Regards,
Tamer Assad
0 Kudos
vucetica
Beginner
901 Views
Tamer, thanks! This works great...I totally missed the fact that my input type isYV12. Thanks a lot.
Aleksandar
0 Kudos
Tamer_Assad
Innovator
901 Views
Hi Aleksandar,

Thank you for sharing the results.

Ying, Many thanks toyou and all the IPP team.

Regards,
Tamer Assad
0 Kudos
Reply