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

Here everybody can post his problems with PhotoLine
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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:
Bild
Bild

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:
Bild
Bild
Bild

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!

Bild
Bild
Bild

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
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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.
Bild
Bild
Bild
Bild
Zuletzt geändert von shijan am Di 31 Dez 2019 16:13, insgesamt 1-mal geändert.
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302
bkh
Betatester
Beiträge: 3674
Registriert: Do 26 Nov 2009 22:59

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

Beitrag von bkh »

shijan hat geschrieben: Di 24 Dez 2019 17:42P.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
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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
Beiträge: 3674
Registriert: Do 26 Nov 2009 22:59

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

Beitrag von bkh »

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
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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:
Bild

Extreme correction of same image up-converted to 32 bit don't produce artefacts:
Bild
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302
gennadiy
Mitglied
Beiträge: 84
Registriert: Di 23 Jan 2018 10:06
Wohnort: Russia

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

Beitrag von gennadiy »

shijan hat geschrieben: Di 24 Dez 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
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

gennadiy hat geschrieben: Mo 30 Dez 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
Beiträge: 84
Registriert: Di 23 Jan 2018 10:06
Wohnort: Russia

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

Beitrag von gennadiy »

shijan hat geschrieben: Mo 30 Dez 2019 11:09
I is obtained in the 32bit.
Note LAB values ​​as they were, and have remained.
3.jpg
4.jpg
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
gennadiy
Mitglied
Beiträge: 84
Registriert: Di 23 Jan 2018 10:06
Wohnort: Russia

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

Beitrag von gennadiy »

shijan hat geschrieben: Mo 30 Dez 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.
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
gennadiy
Mitglied
Beiträge: 84
Registriert: Di 23 Jan 2018 10:06
Wohnort: Russia

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

Beitrag von gennadiy »

shijan hat geschrieben: Mo 30 Dez 2019 11:09
PS:
7.jpg
8.jpg
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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:
Bild

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

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:
Bild
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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:
Bild

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

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
Benutzeravatar
shijan
Mitglied
Beiträge: 1497
Registriert: Mo 23 Dez 2019 15:21
Wohnort: Ukraine

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

Beitrag von shijan »

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:
Bild
Bild
PhotoLine UI Icons Customization Project: https://www.pl32.com/forum3/viewtopic.php?f=3&t=6302