Community
cancel
Showing results for 
Search instead for 
Did you mean: 
gsoucy
Beginner
77 Views

Problem with ippiLabToBGR

Hello,

I am trying to convert a LAB image into a BGR image. I am not getting the expected values when I compare with conversions done with other software (Photoshop). More specifically, I am using this routine:

IppStatus ippiLabToBGR_16u8u_C3R(const Ipp16u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);


According to the doc, the 16U lab dataarefirst converted to original/unscaled LAB value asfollows:

L = L * 100./65535.
a = (a/255. - 128.)
b = (b/255.) - 128.)

When I try simple values, the conversion seems wrong. Here are a few examples:

LAB values 16U values passes toIPP 8u values returned by ippiLabToBGR
------------- --------------------------- -------------------------------------
L= 50 32767 R=46
A= 0 32640 G=47
B= 0 32640 B=48

For a L of 50, we should get a much higher intensity then RGB~=46 as returned now by the routine (it should be close to 128 IMHO)

Here is another example:

LAB values 16U values passes to IPP 8u values returned by ippiLabToBGR Conversion with Photoshop
------------- --------------------------- ------------------------------------- ---------------------------
L= 60 39321 R= 26 R=90
A= -20 27540G= 81 G=154
B= +30 40290B= 55 B=123


The IPP conversion is not even close to the value obtained with Photoshop (which I trust for that).

I suspect that this might be related to gamma-correction but I am not sure. Is there a way to disable gamma-correction?

Am I missing something else? Any help would be appreciated.

Thanks you!

Gilbert
0 Kudos
1 Reply
Sergey_P_Intel1
Employee
77 Views

Quoting - gsoucy
Hello,

I am trying to convert a LAB image into a BGR image. I am not getting the expected values when I compare with conversions done with other software (Photoshop). More specifically, I am using this routine:

IppStatus ippiLabToBGR_16u8u_C3R(const Ipp16u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);


According to the doc, the 16U lab dataarefirst converted to original/unscaled LAB value asfollows:

L = L * 100./65535.
a = (a/255. - 128.)
b = (b/255.) - 128.)

When I try simple values, the conversion seems wrong. Here are a few examples:

LAB values 16U values passes toIPP 8u values returned by ippiLabToBGR
------------- --------------------------- -------------------------------------
L= 50 32767 R=46
A= 0 32640 G=47
B= 0 32640 B=48

For a L of 50, we should get a much higher intensity then RGB~=46 as returned now by the routine (it should be close to 128 IMHO)

Here is another example:

LAB values 16U values passes to IPP 8u values returned by ippiLabToBGR Conversion with Photoshop
------------- --------------------------- ------------------------------------- ---------------------------
L= 60 39321 R= 26 R=90
A= -20 27540G= 81 G=154
B= +30 40290B= 55 B=123


The IPP conversion is not even close to the value obtained with Photoshop (which I trust for that).

I suspect that this might be related to gamma-correction but I am not sure. Is there a way to disable gamma-correction?

Am I missing something else? Any help would be appreciated.

Thanks you!

Gilbert

Hi,

To get result like Photoshop you should work with gamma corrected RGB.

Use ippi functions:

- ippiGammaFwd which performs gamma-correction of the source image with RGB data.

- ippiGammaInv which converts a gamma-corrected RGB image back to the original RGB image.

Reply