PhotoLine fails the color blending test

Here everybody can post his problems with PhotoLine
maho
Mitglied
Beiträge: 123
Registriert: So 18 Mai 2003 02:02

PhotoLine fails the color blending test

Beitrag von maho »

PhotoLine fails the color blending test, as described by this video:

Minute Physics

Original image:

Bild

After Gaussian Blur (50):

Bild

If you check using the Color Picker tool, you can see that PhotoLine is using a simple linear interpolation to blending the two colors, i.e.

blend = alpha*color1 + (1-alpha)*color2, alpha from 0 to 1

whereas the video claims the operation should be:

blend = sqrt(alpha*color1^2 + (1-alpha)*color2^2)

e.g., the 50/50 blended value of (255,0,0) and (0,255,0) is not (127,127,0), but should be (180,180,0).

Please consider/discuss.
Eurgail
Mitglied
Beiträge: 379
Registriert: So 06 Jul 2014 23:02

Re: PhotoLine fails the color blending test

Beitrag von Eurgail »

If it's the standard, can it be false? :-)
You can correct it the same way as in PS (in the video) in the color profile options of the document.
Zuletzt geändert von Eurgail am Do 03 Sep 2015 18:07, insgesamt 1-mal geändert.
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2452
Registriert: Sa 12 Mai 2012 21:38

Re: PhotoLine fails the color blending test

Beitrag von Herbert123 »

Aha, so that explains it! I always wondered about the underlying reason why Gaussian blurring would result in terrible looking blending at times.

I agree, this is easily fixed.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2452
Registriert: Sa 12 Mai 2012 21:38

Re: PhotoLine fails the color blending test

Beitrag von Herbert123 »

This also occurs when drawing with a smooth brush.
Untitled.jpg
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Benutzeravatar
Hoogo
Beta Tester
Beiträge: 4169
Registriert: So 03 Jul 2005 13:35
Wohnort: Deutschland

Re: PhotoLine fails the color blending test

Beitrag von Hoogo »

You can have quite some fun with calculations on values that have a "wrong" gamma applied. This is a reason why 32Bit is usually used with Gamma=1.

A quite famous example is scaling the Dalai Lama, who scales fine with Gamma=1, but bad with Gamma 2.2. BKH once mentinoned that this example is a bit like cheating, you could construct pictures that scale bad with Gamma=1, but good with Gamma 2.2

It will be fixed if you convert to a color space with linear gamma. Converting to 32Bit will do that for you. 8Bit and linear gamma don't go well together.
----------------
Herr Doktor, ich bin mir ganz sicher, ich habe Atom! /Doctor, doctor, I'm sure, I've got atoms!
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2452
Registriert: Sa 12 Mai 2012 21:38

Re: PhotoLine fails the color blending test

Beitrag von Herbert123 »

Eurgail hat geschrieben:If it's the standard, can it be false? :-)
You can correct it the same way as in PS (in the video) in the color profile options of the document.
I guess this is one of the reasons why a linear workflow is preferred in higher level compositing? But at the end of the pipeline it is always converted to a non-linear output.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2452
Registriert: Sa 12 Mai 2012 21:38

Re: PhotoLine fails the color blending test

Beitrag von Herbert123 »

Hoogo hat geschrieben:You can have quite some fun with calculations on values that have a "wrong" gamma applied. This is a reason why 32Bit is usually used with Gamma=1.

A quite famous example is scaling the Dalai Lama, who scales fine with Gamma=1, but bad with Gamma 2.2. BKH once mentinoned that this example is a bit like cheating, you could construct pictures that scale bad with Gamma=1, but good with Gamma 2.2

It will be fixed if you convert to a color space with linear gamma. Converting to 32Bit will do that for you. 8Bit and linear gamma don't go well together.
But should the blending math be corrected then when working in 8 and 16bpc mode in Photoline? I think it ought to.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2452
Registriert: Sa 12 Mai 2012 21:38

Re: PhotoLine fails the color blending test

Beitrag von Herbert123 »

Wrong example. Never mind! :-)
Zuletzt geändert von Herbert123 am Do 03 Sep 2015 22:11, insgesamt 2-mal geändert.
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
bkh
Beta Tester
Beiträge: 3687
Registriert: Do 26 Nov 2009 22:59

Re: PhotoLine fails the color blending test

Beitrag von bkh »

maho hat geschrieben:If you check using the Color Picker tool, you can see that PhotoLine is using a simple linear interpolation to blending the two colors, i.e.

blend = alpha*color1 + (1-alpha)*color2, alpha from 0 to 1

whereas the video claims the operation should be:

blend = sqrt(alpha*color1^2 + (1-alpha)*color2^2)
Still a bit off – colour1 and colour2 must be corrected using the gamma curve in the colour profile, then the result has to be converted back using that curve. But of course, assuming a gamma value of 2 is much closer to common gamma values than gamma = 1 from the first formula.
Herbert123 hat geschrieben:But should the blending math be corrected then when working in 8 and 16bpc mode in Photoline? I think it ought to.
Problem is that alpha blending in PDF is defined in the same way as in PL, so if you want to export a layered PDF, you'll have to use its definitions or your PDF will look different from the PL file. Same story for PSD import. All these simplified blending rules date back from times when computers were much slower and had much less RAM.

Btw., if you want to use physically correct alpha blending, you'll have to do the maths in 32 bit float anyway, so working in 32 bit from the beginning is no overhead.

Cheers

Burkhard.
maho
Mitglied
Beiträge: 123
Registriert: So 18 Mai 2003 02:02

Re: PhotoLine fails the color blending test

Beitrag von maho »

Hoogo, thanks for the Dalai Lama pix... a neat test of cleverly designed "trick" images, but not exactly what I am getting at here.

I tried this:

Tool->Color->Convert With Color Profile, Dest. Profile = ProPhoto RGB

This leaves the appearance of the image unchanged, but changes the numerical values of the pixels:

(255,0,0) -> (179,70,26)
(0,255,0) -> (138,237,77)
(0,0,255) -> (85,34,236)

Then I try the Gaussian Blur as before, and get this:

Bild

Visually, the image looks much better, but now the pixel values are all messed up. My understanding is limited, but I'm guessing the "color profile" is somehow embedded in the picture, and the web browser reads this and uses this to "reverse engineer" it for proper display. If I take a screen cap of the above image, I get this image, which seems to have no color profile:

Bild

You can see that the pixel values are closer but not quite what they started as.

I'm pretty confused at this point, but I'm have doubts that the default behavior is correct.
bkh
Beta Tester
Beiträge: 3687
Registriert: Do 26 Nov 2009 22:59

Re: PhotoLine fails the color blending test

Beitrag von bkh »

Herbert123 hat geschrieben:Blending blue with yellow generates green, right?
Only when using subtractive mixing with real colours. Even in CMYK colours, this gives a shade of grey ideally.
Herbert123 hat geschrieben:We get a grey, because the RGB values of 255,255,0 and 0,0,255 average out at 128,128,128.
Perfectly fine, and independent of the mixing formula. However, the interpretation of (128,128,128) differs according to the chosen gamma curve.

Cheers

Burkhard.
maho
Mitglied
Beiträge: 123
Registriert: So 18 Mai 2003 02:02

Re: PhotoLine fails the color blending test

Beitrag von maho »

bkh hat geschrieben: Still a bit off – colour1 and colour2 must be corrected using the gamma curve in the colour profile, then the result has to be converted back using that curve. But of course, assuming a gamma value of 2 is much closer to common gamma values than gamma = 1 from the first formula.

Burkhard.
Thanks for the response, Burkhard. I've actually never used Color Profile before, just been experimenting with it for the last 15 minutes.

Is it possible to have PhotoLine use a "default" gamma value (of about 2) automatically so that images blend properly? EG, some global gamma value that is used for all blending, not just Gaussian Blur, but Color Gradient tool, Paint Brush, Eraser, anti-aliasing, everywhere? It seems you should be able to do this without messing with Color Profiles.

I am vaguely aware that we are all using different monitors, so "correct" for me may not mean "correct" for you.
bkh
Beta Tester
Beiträge: 3687
Registriert: Do 26 Nov 2009 22:59

Re: PhotoLine fails the color blending test

Beitrag von bkh »

maho hat geschrieben:Hoogo, thanks for the Dalai Lama pix... a neat test of cleverly designed "trick" images, but not exactly what I am getting at here.
Same problem, anyway. Scaling, like blurring, mixes adjacent colours.

maho hat geschrieben:Visually, the image looks much better, […]
No surprise, if the colour component values are closer, the results of the two formulas are close as well. This is the reason why the simplified formula works relatively well in most "natural" cases, i.e., if you stay away from pure RGB colours.
maho hat geschrieben:My understanding is limited, but I'm guessing the "color profile" is somehow embedded in the picture, and the web browser reads this and uses this to "reverse engineer" it for proper display.
Yes, the first image has a ProPhoto RGB profile. The rest depends on the web browser you use. Safari and Firefox (not sure if by default) do this, but IE is notorious for getting this wrong. Ideally, the web browser uses the image profile and converts colours to the display profile of your monitor.

If you want the original colour values back, then flatten the image in PL and convert back to sRGB (or whatever colour space you started with). There will be rounding errors if you work in 8 bit mode.
maho hat geschrieben:If I take a screen cap of the above image, I get this image, which seems to have no color profile:
[…]
You can see that the pixel values are closer but not quite what they started as.
The screen cap probably contains the display RGB values (relative to your monitor profile), not sRGB values.

Cheers

Burkhard.
maho
Mitglied
Beiträge: 123
Registriert: So 18 Mai 2003 02:02

Re: PhotoLine fails the color blending test

Beitrag von maho »

Thanks Burkhard.

At the risk of being redundant, is there any way to get PhotoLine to blend colors "correctly" (that is, with a implied Gamma of 2) without messing with all the color profile stuff?
maho
Mitglied
Beiträge: 123
Registriert: So 18 Mai 2003 02:02

Re: PhotoLine fails the color blending test

Beitrag von maho »

According to wikipedia, the default gamma value for most computer displays is 2.2, so I might argue that would be a better default value than 2.

Here's a little picture I made that shows what you get 50/50 blending red with green, using gamma values of 1, 2, and 2.2(from top to bottom). Which looks the "best"?

Bild

At least on my monitor, the top blend looks noticeably darker than the pure red/pure green.

I can also confirm that IOS Safari does not know how to read and adjust for the gamma/color profile embedded in that PNG file.