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

Rmoving the Alpha channel from an RGB

brian_barber
Beginner
1,066 Views
I have RGBs with an alpha channel to do some blending (using ippiAlphaComp_8u_AC4R). After the blending is done I need to convert the output rgb into yuv4:2:0. I don't care if I lose the alpha channel during this process.
Currently, I'm removing the alpha channel by walking through the RGB and copying only the RGB into a new buffer. There must be a better way.
Thanks
0 Kudos
7 Replies
Vladimir_Dudnik
Employee
1,066 Views

Hello,

you can consider to useIPP functions like ippiBGRToYCbCr411_8u_AC4P3R or ippiBGRToYCbCr420_8u_AC4P3R

Regards,
Vladimir

0 Kudos
brian_barber
Beginner
1,066 Views

Hi,

Thanks for the response.

I guess I'm not 100% sure. I need the image to be in YUV420 format so I've been using calls like ippiRGBToYUV420. Is there much of a difference b/w YUV420 and YCbCr420?

Perhaps I'm doing something wrong but I can'ty get ippiBGRToYCbCr420_8u_AC4P3R to compile. "error C3861: 'ippiBGRToYCbCr420_8u_AC4P3R': identifier not found, even with argument-dependent lookup". ??

Thanks

0 Kudos
brian_barber
Beginner
1,066 Views

Hi,

I found and fixed my compile problem. It works but the resulting image is more "washed-out" than if I removed the alpha channel using ippiCopy_8u_AC4C3R and then converted using ippiRGBToYUV420_8u_C3P3R. Do you have a guess why this might be?

thanks,

Brian

0 Kudos
Vladimir_Dudnik
Employee
1,066 Views

Hi Brian,

what do you mean under "washed-out"? Could you please attache sample of incorrect frame (and correct one if you have).

Thanks,
Vladimir

0 Kudos
brian_barber
Beginner
1,066 Views

I attached my code as blend_snippet

The "washed out" bitmap (output_ycbcr.bmp)was created using ippiBGRToYCbCr420_8u_AC4P3R

The other bitmap (output_copy_removes_alpha.bmp) uses a copy to remove the alpha and then converts using ippiRGBToYUV420_8u_C3P3R.

Thanks for your help

0 Kudos
Vladimir_Dudnik
Employee
1,066 Views
Yes, I see, it was a bad idea, sorry. The reason is that in second case you convert from BGR to YCbCr and after that from YUV to RGB, but these functions use different equations to calculate out pixels (you can see IPP manual or ippcc.h file for the details)
// Y = 0.257*R' + 0.504*G' + 0.098*B' + 16
// Cb = -0.148*R' - 0.291*G' + 0.439*B' + 128
// Cr = 0.439*R' - 0.368*G' - 0.071*B' + 128
// Y' = 0.299*R' + 0.587*G' + 0.114*B'
// U = -0.147*R' - 0.289*G' + 0.436*B' = 0.492*(B' - Y' )
// V = 0.615*R' - 0.515*G' - 0.100*B' = 0.877*(R' - Y' )
Please submit new functionality request if you fill that the first suggestion does not fit your needs.
Regards,
Vladimir
0 Kudos
brian_barber
Beginner
1,066 Views
No problem. Thanks for the help
0 Kudos
Reply