Pages: [1]   Go Down

Author Topic: Fun With Gamma or Why I sometimes work in Gamma=1  (Read 971 times)

Doug Gray

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2197
Fun With Gamma or Why I sometimes work in Gamma=1
« on: January 21, 2019, 06:53:51 pm »

Here's an interesting example of artifacts that can be generated when doing Photoshop work in standard colorspaces. This image, in sRGB, actually started out as a gray looking rectangle. The below attached images are in standard sRGB and a modified, gamma=1, sRGB. On a profiled, color managed setup they should look exactly the same. If the monitor profile is marginal, you may see some slight variation between the left and right sides.

Then I ran a wide, blurring brush over the right side. It turned into into a colored strip. How does this happen?

Well, Photoshop is rather stupid in many of the algorithms it uses. In particular those that upsize/downsize or blur images. The reason is that it just mathematically averages the RGB values without considering the encoding gamma. The average of RGB 254,254,254 and 0,0,0 is calculated to be 127,127,127. This is fine were the gamma=1, but for gamma=2.2, it's not. The average should be done in gamma=1 which means RGB 187,187,187.  The dark gray area at the top of this image is caused by the blur tool averaging in sRGB gamma.

The original images have an alternating checkerboard of pixels on the right hand side. The top is alternating black/white followed below by differing alternating pixel colors that average out as a light gray (50% reflectance). The net effect is that the sRGB image (attached below), viewed in Photoshop at 100% zoom, just looks like a gray rectangle. But it won't print that way. If you upsize or downsize the sRGB one, but not the modified gamma=1 sRGB version, in Photoshop it will show horizontal, colored strips. If you run the blur tool over it you will get the same effect shown.

The cyan/greens/yellows that follow show the same problem.




I encourage people to download the attached files, one in gamma=1 the other in sRGB gamma and try out resizing and blurring in Photoshop to get a feel for what's going on. Zoom in and look at the pixels to see how the effect is done.

This is more of an interesting demonstration as the effect rapidly disappears if the image being printed is not both super sharp and has things in it that rapidly change pixel to pixel. You might see differences in subjects like referees with black/white striped shirts in sharp images when downsized to small prints such that the stripes blend.

So, whenever I upsize or downsize in PS for printing I typically convert to gamma=1 first. With the exception of the options designed to retain detail. These look for diagonal edges and expect a normal gamma. At least for some of their work. So you might want to test both approaches using these options.

ADDED:
The attached images that also show below, will show pretty badly colored right hand sides. Trust me. They look like very nice gray rectangles in photoshop at 100% zoom and nothing like what you probably see on the browser.
« Last Edit: January 21, 2019, 07:10:01 pm by Doug Gray »
Logged

simon.garrett@iee.org

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 55
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #1 on: January 22, 2019, 03:33:55 am »

Interesting!  Perhaps that's why Lightroom (to my understanding) uses linear gamma for processing. (ProPhoto RGB with linear gamma for processing, but with sRGB TRC for pixel RGB values and histograms.)
Logged

32BT

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3095
    • Pictures
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #2 on: January 22, 2019, 03:53:18 am »

I'm inclined again to ask whether gpu enabled/disabled makes a difference.

I also recall Photoshop used to have a setting where image operations are forced in gamma= 1.0 but I think that was primarily for blending purposes, not sure if it affects blurring tools etc.

It was also one of those problems I encountered on the introduction of the iPad. OpenCL is supposed to be gamma 1.0 by definition, but that didn't pan out properly. It was kind of the point where I gave up, no longer willing to cope with all the multitude of variations that continuously need double checking and lack any form of consistency.

Imagine having done everything to ensure a proper pipeline, only to find on release that half the graphics cards or some older driver introduce some kind inconsistency.

We have to give Adobe some credit for willing to cope with that and providing us with at least a slightly reasonable product that still tries to implement the best possible processing experience.
Logged
Regards,
~ O ~
If you can stomach it: pictures

Aram Hăvărneanu

  • Full Member
  • ***
  • Offline Offline
  • Posts: 214
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #3 on: January 22, 2019, 04:13:12 am »

Hi Doug,

Here is an article detailing this problem with results from a wide variety of software: http://www.ericbrasseur.org/gamma.html.
Logged

Doug Gray

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2197
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #4 on: January 22, 2019, 12:45:42 pm »

I'm inclined again to ask whether gpu enabled/disabled makes a difference.

I also recall Photoshop used to have a setting where image operations are forced in gamma= 1.0 but I think that was primarily for blending purposes, not sure if it affects blurring tools etc.

GPUs do not affect it.

No doubt this is just something historical. Ignoring gamma is computationally simple. At the time Photoshop was initially created it would have been quite a bit slower to correct for gamma during these operations which requires floating point operations. The workaround was converting the image to gamma=1. Doing the needed operations, and converting back. In 16 bit mode there is no negative consequence in 16 bit mode.
Logged

Doug Gray

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2197
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #5 on: January 22, 2019, 12:46:51 pm »

Hi Doug,

Here is an article detailing this problem with results from a wide variety of software: http://www.ericbrasseur.org/gamma.html.

Interesting discussion and examples. Useful for anyone that is confused about where and how gamma affects things.
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20646
  • Andrew Rodney
    • http://www.digitaldog.net/
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #6 on: January 22, 2019, 02:17:53 pm »

Interesting!  Perhaps that's why Lightroom (to my understanding) uses linear gamma for processing. (ProPhoto RGB with linear gamma for processing, but with sRGB TRC for pixel RGB values and histograms.)
It's because it's primarily a raw processor (using the ACR engine) and raw data is encoded in a linear TRC.
Logged
http://www.digitaldog.net/
Author "Color Management for Photographers".

DP

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 727
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #7 on: January 23, 2019, 08:40:45 pm »

It's because it's primarily a raw processor (using the ACR engine) and raw data is encoded in a linear TRC.

except by the time ACR/LR starts using ProPhoto primaries for the first time there are no raw data present (it is demosaicked, WB'd and converted to cieXYZ(D50))  ;D
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20646
  • Andrew Rodney
    • http://www.digitaldog.net/
Re: Fun With Gamma or Why I sometimes work in Gamma=1
« Reply #8 on: January 23, 2019, 09:06:53 pm »

except by the time ACR/LR starts using ProPhoto primaries for the first time there are no raw data present (it is demosaicked, WB'd and converted to cieXYZ(D50))  ;D
What? The processing color space is what it is; ProPhoto primaries and TRC 1.0 as by design of Thomas Knoll.
Directly from Thomas in terms of the ACR processing path:
First convert from camera native space to linear PhotoRGB.
From Eric Chan on this forum:
Hi folks, the internal reference scene-referred space in Camera Raw & LR is indeed RIMM (ProPhoto linear). However, that does not mean that all internal image processing operations are performed directly in that space. The actual color space used for an operation depends on the routine (e.g., noise reduction, clarity, fill light, HSL adjustments, etc.). The important thing is that the entire process is color-managed so that we can always get to & from the reference space. All of this is done automatically, starting from the source raw image data.
So you're suggesting linear ProPhoto isn't because of the original encoding of the raw?
Logged
http://www.digitaldog.net/
Author "Color Management for Photographers".
Pages: [1]   Go Up