Really lossless convert from RGB to LAB possible only in 32 bit depth

Here everybody can post his problems with PhotoLine
User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Tue 24 Dec 2019 17:42

Here is one very interesting thing i figure during Photoline testing. There is a not too widely known problem with data loss due convert to LAB from wide gamut RGB color spaces. It is common to all existing graphic editing apps. In short - for some reason imaginary colors that exists in Wide color spaces are usually hard clipped when converted to LAB. This is easy to inspect with synthetic gradient created in 16bit wide color space that represents all possible colors. The original gradient created in 16bit ProPhoto RGB looks like this:
Image
Image

When we convert it to LAB we can see some clipping due some amount of imaginary colors in ProPhoto RGB color space. Those colors are lost forever now:
Image
Image
Image

And here is the fix for this problem that i found by accident during Photoline testing:
1. Up-convert mage to 32 bit.
2. Convert to LAB.
Perfect transform of all colors including imaginary colors. No any colors loss!

Image
Image
Image

P.S. I am not to technical and can not explain the nature of this bit depth phenomenon, but hope someone from developers team may explain it.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Tue 24 Dec 2019 19:03

Here is one more example. This is ACES color space. It is way larger than ProPhoroRGB and so have way more imaginary colors. As you can see it produce really huge colors clipping if RGB to LAB transform is done in 16 bit.
Image
Image
Image
Image
Last edited by shijan on Tue 31 Dec 2019 16:13, edited 1 time in total.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

bkh
Betatester
Posts: 3651
Joined: Thu 26 Nov 2009 22:59

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by bkh » Wed 25 Dec 2019 15:51

shijan wrote:
Tue 24 Dec 2019 17:42
P.S. I am not to technical and can not explain the nature of this bit depth phenomenon, but hope someone from developers team may explain it.
In PL, 32 bit images use floating point numbers to represent colour values. This means that colours outside the range of a colour space can be represented using values below zero or above one (8 and 16 bit images use integers to represent the 0…1 range for each colour channel). In this way, with 32 bit images, you can even do lossless conversions from Lab or ProPhotoRGB to sRGB and back. Not all of PL's filters support values outside the 0…1 range, though, so you may experience clipping and other strange effects.

Cheers

Burkhard

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Wed 25 Dec 2019 20:16

Interesting. Is it any Indicator in UI which adjustment layer support 32 bit processing and which is not?
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

bkh
Betatester
Posts: 3651
Joined: Thu 26 Nov 2009 22:59

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by bkh » Thu 26 Dec 2019 00:16

Don't get me wrong – afaik, all adjustment layers support 32 bit images. Just keep in mind that results may not be what you expect when colours are outside the 0…1 range. It's probably too technically difficult to explain the effects for every single filter. My advice would be not to rely on out of range colours unless you know (or are willing to experiment with) what you are doing.

Cheers

Burkhard

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Thu 26 Dec 2019 03:19

I just never thought that 32 bit depth may be somehow related to color spaces transformations. In my head it was related only to wider dynamic range (tonal values) but not to out gamut negative color values. So one more useful thing to know.
32 bit depth workflow (and as result precise Curves and Histograms tools) is the only main reason why i dancing around this app. Yet i tested simple tools like Histogram adjustment, Curves, Expose, LUTs - all works very well and very fast in 32 bit.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Fri 27 Dec 2019 02:00

Here is another interesting example. This time it is not a LAB. Just film scan in wide RGB color space:

Extreme correction in 16 bit produce artefacts:
Image

Extreme correction of same image up-converted to 32 bit don't produce artefacts:
Image
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

gennadiy
Mitglied
Posts: 48
Joined: Tue 23 Jan 2018 10:06
Location: Russia

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by gennadiy » Mon 30 Dec 2019 10:51

shijan wrote:
Tue 24 Dec 2019 17:42
The gradient was created in Argyll (timage -t -x tst.tif)?
And there he created without specifying the color space.
So that the color profile you want to assign to the PL.
In this case, the gradient is already spoiled.
But in general, in PhotoShop similar pattern occurs.
I understand this is the work of CMS?

1.jpg
2.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Mon 30 Dec 2019 11:09

gennadiy wrote:
Mon 30 Dec 2019 10:51
The gradient was created in Argyll (timage -t -x tst.tif)?
[/quote]

I created that test gradient directly in PhotoLine in specified color space. Here is how:
1. Create new document with ProPhoto or ACES color space.
2. Choose rainbow gradient tool from presets
3. Create gradient from left to right edge (by holding Alt to snap to edges and Shift to keep it parallel)
4. create new layer.
5. Choose greyscale gradient preset
6. create top to bottom gradient (by holding Alt to snap to edges and Shift to keep it parallel)
7. set layer blend mode to Hard Light.

That's it.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

gennadiy
Mitglied
Posts: 48
Joined: Tue 23 Jan 2018 10:06
Location: Russia

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by gennadiy » Tue 31 Dec 2019 14:34

shijan wrote:
Mon 30 Dec 2019 11:09
I is obtained in the 32bit.
Note LAB values ​​as they were, and have remained.
3.jpg
4.jpg
You do not have the required permissions to view the files attached to this post.

gennadiy
Mitglied
Posts: 48
Joined: Tue 23 Jan 2018 10:06
Location: Russia

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by gennadiy » Tue 31 Dec 2019 15:06

shijan wrote:
Mon 30 Dec 2019 11:09
And when working without a profile is obtained as follows:
5.jpg
6.jpg
But in general, PS works as well.
Most likely, this is the work of CMS.
You do not have the required permissions to view the files attached to this post.

gennadiy
Mitglied
Posts: 48
Joined: Tue 23 Jan 2018 10:06
Location: Russia

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by gennadiy » Tue 31 Dec 2019 15:13

shijan wrote:
Mon 30 Dec 2019 11:09
PS:
7.jpg
8.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Tue 31 Dec 2019 15:42

I have no idea what you try to explain. But yes, Photoshop as well as any other app that converts to LAB in 16 bit will clip colors.

Here is original 16 bit gradient created in ACES color space. You can see values under 0 and over 100 in LAB color picker point sample:
Image

Here is same image up-converted to 32 bit and converted to LAB. All values under 0 and over 100 are preserved. No clipping:
Image

Here is image converted to LAB in 16 bit depth. All values under 0 and over 100 are clipped to 0 and 100 max. Colors are lost:
Image
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Sat 18 Jul 2020 22:07

It seems we have a problem - Little CMS color transforms don't support 32 bit depth. Here is side by side test:

Apple Color Management 32 bit ACES to LAB to sRGB:
Image

Little CMS (turned ON in PhotoLine preferences) 32 bit ACES to LAB to sRGB:
Image

Example PLD file https://www.dropbox.com/s/zon5vvr4vk8x0 ... d.zip?dl=0
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302

User avatar
shijan
Mitglied
Posts: 408
Joined: Mon 23 Dec 2019 15:21

Re: Really lossless convert from RGB to LAB possible only in 32 bit depth

Post by shijan » Sun 19 Jul 2020 10:57

Also it seems LAB clips only if source image Lightness channel have negative value.
Note that example gradient is pure synthetic generated image. Same color data probably impossible in any real life photo.

Here is how Apple CMS vs Little CMS "see" negative lightness values in gradient generated in ACES color space. With Little CMS it is just impossible to see negative values of Lightness channel:
Image
Image
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302