"Gamma error in picture scaling"?

Moderator: jsachs

MarkT
Posts: 367
Joined: April 24th, 2009, 2:07 pm

"Gamma error in picture scaling"?

Post by MarkT »

Hi,

Just wondering if anyone has read this article "Gamma error in picture scaling" by Eric Brasseur (http://www.4p8.com/eric.brasseur/gamma.html)? I tried his test with PWP 5.0.1.7 and found the result to be "incorrect" as described in the article.

I'd be curious to know if anyone can confirm what's going on, and perhaps determine if it might be something worth looking into?

Mark
den
Posts: 856
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: "Gamma error in picture scaling"?

Post by den »

Interesting link... and I can confirm that PWP5 does not seem to have gamma correct scaling.

I took the "gamma_colors.jpg" image from the web page and reduced it 50% with the Resize transform's default bicubic method settings. I then converted the "gamma_colors.jpg" image from 2.22 gamma to a 1.0 gamma image; reduced it 50%; and then converted the gamma from 1.0 back to 2.22...

Img1: Resize transform reduced 50%, default bicubic settings, no gamma correction
Img2a: Absolute Difference between Img1 and Img3, 25% dynamic range difference
Img2b: Img2a expanded to full range
Img3: Resize transform reduced 50%, default bicubic settings, gamma correction

Image

Does this have significance to a real type image rather than a designed test image? From the following examples, I would conclude that significance is relatively minor and the effect occurs in the vicinity of an image's edges [high freguencies] while leaving the smoother image areas [low frequencies] relatively unchanged... i.e., the gamma correct scaled image will require less edge sharpening than an uncorrected gamma scaled image... for both images, the absolute difference Img2 dynamic range difference was around 15%. Img2 is shown at 'full dynamic range' and the Img1 and Img3 images are 800x533 pixels reduced from 3456x2406 pixel starting images. Img1 reduced without gamma correction and Img2 reduced with gamma correction. Posting resolution will not show visible differences.

Example1:
Image

Example2:
Image

Summary: A refinement to the Resize transform would be in the incorpration of the Input image's gamma to 1.0 before actually scaling and then reconverting it back to its original gamma after the scaling by which ever method selected is completed.

Please advise if anyone needs/wants further help with the steps I used to convert gammas with PWP5's Adjust Gamma tranform.
MikeG
Posts: 243
Joined: April 25th, 2009, 4:36 pm
What is the make/model of your primary camera?: Panasonic G1
Location: Sydney, Australia

Re: "Gamma error in picture scaling"?

Post by MikeG »

Den,

Explanation, please. I can't reproduce what you've done.

Thanks, Mike.
den
Posts: 856
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: "Gamma error in picture scaling"?

Post by den »

From the linked reference:
Assume a gamma of 2.2
The idea is simple: impose a gamma of 0.454545, work on the image, then impose back a gamma of 2.2.

But:

This is an approximation. Imposing a gamma of 0.454545 is quite close to making an sRGB-encoded image linear. This will do in most cases... It should be perfect for photographs. But keep in mind it is not technically perfectly correct. If you're working for the industry or on scientific data, you may get reproaches.
To produce an approximate gamma correct scaled image using PWP5:

Step1: Open or click on the starting image, Img0
Step2: Open Gray\Gamma Adjust and move the slider to the right until the gamma factor reads 2.22 for an Input gamma of 2.22, click OK. This creates a dark, linear gamma image of Img0, Img1.
Step3: Click on Img1 and open the Resize transform. Resize to preferences. Click OK, creating Img2, a resized image of the linear gamma Img1.
Step4: Click on Img2; open Gray\Gamma Adjust; move the slider to the left until the gamma factor reads 0.45 for an Input gamma of 2.22; click OK creating Img3, the gamma correct scaled image. This restores a gamma of 2.22 and lightens Img2.
Dieter Mayr
Posts: 453
Joined: April 24th, 2009, 11:47 am
What is the make/model of your primary camera?: Nikon D700
Location: Salzburg / Austria

Re: "Gamma error in picture scaling"?

Post by Dieter Mayr »

What i do not really understand in this process is the behaviour of the Gamma Adjust transformation.
When linearizing the image from a gamma 2.22 to gamma 1.0 it needs a setting of Input Gamma 2.22 and a factor of 2.22 which gives a Output Gamma of 4.93 (The same result is a Input Gamma of 1.0 which gives a Output Gamma of 2.22).
Shouldn't a Input Gamma of 2.22 and a Output Gamma of 1.0 (with a Factor of 0.45) result in a linearisation ?

The whole procedure can be packed in a workflow if one has to shrink images who might be critical on that effect.
Dieter Mayr
tomczak
Posts: 1370
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: "Gamma error in picture scaling"?

Post by tomczak »

Dieter,

The simplistic way I understand it is that there are three places where gamma and inverse gamma are applied:

1) the response of camera sensor (the normalized RAW values) is roughly linear with respect to the light intensity that falls on it - there is no gamma here
2) the pixel values of the resulting image are proportional to the camera sensor response raised to the power of 1/gamma (say 0.45)
3) the brightness of the pixels of the display monitor are proportional to the pixel values raises to the power of gamma (say 2.22)
4) the human vision system perceives lightness as somewhat proportional the monitor brightness raised to the power of 1/gamma (say 0.45 again).

I think that the linearity that people are after here is not between the normalized pixel values and the brightness of the monitor (i.e. pt. 3), but rather between the camera sensor response and pixel values (i.e. pt. 2). Since normally RAW processing has already raised the pixel values to the power of e.g. 0.45, the Gamma Adjust needs a Gamma Factor of 2.22 to nullify it. The selection of Input Gamma is just a reference that should/could be set to your current display gamma; so if it's set to 2.22 the Output Gamma will came out as ~4.9. What it tells me is that if the RAW processing indeed used gamma of 0.45 to produce the image, my Gamma Adjusted output pixels values would be again linearly related to original RAW values (and also would be best viewed with a monitor with gamma 4.9...)

Your display monitor brightness still raises the normalized pixel values of the image to the power of 2.22? no matter what you have done to these pixels before.

I understand the Gamma Factor is an exponent multiplier that allows to transform the image pixel values to look the same on a display system having different gamma (i.e. the Input Image on a display with Input Gamma will look the same as the Output Image on a display with Output Gamma - since your particular display gamma on which you process images stays constant, the input and output images look different).

With Gamma Factor=0.45, the output image would look normal (the same) on a display with gamma 1 instead of 2.22. This also means that such-transformed output image pixel values will be even less linear with respect to the camera sensor response (i.e. the pixel values will be proportional to the normalized RAW values raised to the power of ~0.2).

Does it make any sense?
Maciej Tomczak
Phototramp.com
den
Posts: 856
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: "Gamma error in picture scaling"?

Post by den »

MaciejT...
...that is a great explanation. Often times I do things to get the results I want without fully understanding why... just accepting the settings/adjustments needed to get where I want to go. Thank you for the very considered response to DieterM's question.

DieterM...
...As I routinely downsize 3456x2406 pixel post-processed tiff images to 800x533 pixel jpegs for image posting on my web gallery pages, I have a workflow [.wfl] that has been modified to include gamma correct scaling as well as BilateralSharpen LCE and Edge Sharpening of the downsized image, and conversion to jpeg. I plan to experiment with it for awhile comparing results with the unmodified workflow. I will also at times, further change these reduced images to preference tone/colors with ColorCurves before uploading.

All...
...Be aware that scaling [resizing] can take place elsewhere in PWP than just the Resize transform. For example, Crop/Add Borders at the bottom, Warp, Composite where the Overlay Alignment is something other than 1-point fixed, Layout, etc....
tomczak
Posts: 1370
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: "Gamma error in picture scaling"?

Post by tomczak »

I'm sure most people realize it, but it may be useful to say it here again: changing gamma --> resizing --> changing gamma back procedure may produce marginally better resizing results in some special photographic cases (or be drastically more 'logical' in the specially concocted cases), but it will almost certainly cause banding and image degradation if used on image data with too low bit-depth (say 8/24 bit precision). This holds true even if an original 8/24 bit image is converted to 16/48 bit with Convert Transform - the lower bits are simply filled with zeros, I take it, and back and forth gamma changes will still lack continuity between adjacent values. The true 16/48 bit images may have enough flexibility to withstand such gamma summersault before resizing.
Maciej Tomczak
Phototramp.com
tomczak
Posts: 1370
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: "Gamma error in picture scaling"?

Post by tomczak »

Den, you mentioned using 'edge sharpening' in your resize workflow. Is that in addition to Bilateral Sharpen?, and if so, how do you do that without a benefit of an edge mask (high pass? but I'm still not sure if I understand how it works for sharpening). Cheers and thanks.
Maciej Tomczak
Phototramp.com
den
Posts: 856
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: "Gamma error in picture scaling"?

Post by den »

MaciejT...
...The 'resize workflow' has two Bilateral Sharpen widgits... one for Local Contrast Enhance [LCE] with settings: Amount=65; Blur Radius=20; Blur Threshold=100; Sharpen Factor = 1.20; and Sharpen Threshold=0 and another for EdgeSharpening [no mask] with settings: Amount=38; Blur Radius=2; Blur Threshold=39.22; Sharpen Factor=1.5; and Sharpen Threshold=3.92. For a small image destined for web posting, I do not take the time to create an mid-tone Edge Mask for sharpening... instead, I consider the selected Blur Radius to limit changes in the vicinity of an edge... after all a web image is not necessarily a gallery quality image and the suggested BilateralSharpen settings seem to work generically for a 800x533 pixel image reduced from a 16/48-bit, 3456x2304 pixel tiff starting image.

Your reminder regarding gamma exchanges for gamma correct scaling needing 16/48-bit depths is well made and is also pointed out in the linked article of the OP... I perform all my own post processing with 16/48-bit tiff working images, so I just take it for granted others are doings so as well since PWP has the complete capability and algorithms in all of its features to do so...

All...
...I have spent more time this morning experimenting, comparing, testing, and evaluating the impact of PWP's apparant "Gamma error in picture scaling" and while present, it has little or no impact of significance when taking into account my normal post-processing activities to produce a 'scaled' preference image which may include color balancing, tone mapping, color enhancements, local contrast enhancement, and sharpening as these activities either mask or correct the "gamma error".

PWP remains my editor of choice!!!
Post Reply