Gamma Corrected Down-sizing -- just 4 fun!

Please use this forum to post bug reports, feature requests, tips, etc. for beta versions of Picture Window Pro 8

Moderator: jsachs

Locked
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

Gamma Corrected Down-sizing -- just 4 fun!

Post by den »

...
Ref: PWP 8.0.exe 190111

Something that may be of interest... ...a nuance in down-scaling is to resize the linear version (gamma = 1.00) of the original image...

The following workflow will down-size an image to 600px wide (chosen because the message board accepts up to 600x600px images) with a gamma (2.22) corrected version and without gamma correction.

The PWP8 browser workflow:
Downsize to 600px.jpg
Downsize to 600px.jpg (49.94 KiB) Viewed 1845 times
The script: " Downsize to 600px with-without Gamma Correction.script "
------------------------------------------------------------------------------------------------------
script 1.0
color_management enabled 1 on_mismatch 0 on_batch_mismatch 0 acs_profile ″sRGB Color Space Profile.icm″ gray_acs_profile ″Gamma 2.2.icm″ wcs_profile ″sRGB Color Space Profile.icm″ gray_wcs_profile ″Gamma 2.2.icm″ monitor_curves_file ″″ monitor_curves_enabled 0

image index 1 caption ″5-DSCF2121_16x9r.tif″ saved_as ″″ saved_on ″″ parent -1 bypass -1 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴file_open 0 n_files 1 current 0 show_progress 1 from_default 0 file1 ″″ time1 ″″‴
end_image

splitter index 6 parent 1 n_branches 2 caption ″Splitter″

side_branch index 8 parent 6 branch_number 1 caption ″No Gamma Correction″

image index 9 caption ″Resize 600px 100dpi Bicubic″ saved_as ″″ saved_on ″″ parent 8 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴resize 0 onx 600 ony 338 dpi 100 memory 80901504 iunits 0 wunits 0 runits 0 resample 0 set 0 method 2 sharpen -0.75 display 1 auto_preview 1‴
end_image

image index 10 caption ″Sharpen″ saved_as ″″ saved_on ″″ parent 9 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴sharpen 0 kernel 0 maxovershoot 0.0667 maxundershoot 0.1000 threshold 2 strength 1.2500 amount 0.8750 -1 0 0 ″Amount: ″ ″Mask″ display 2 sync_scroll 1 auto_preview 1‴
end_image

side_branch index 7 parent 6 branch_number 0 caption ″Gamma Correction″

image index 2 caption ″De-Gamma 2.22″ saved_as ″″ saved_on ″″ parent 7 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴gamma_adjust 0 gray 0 rgamma 2.2200 ggamma 2.2200 bgamma 2.2200 amount 1 -1 0 0 ″Amount: ″ ″Mask″ display 1 sync_scroll 1 auto_preview 1‴
end_image

image index 3 caption ″Resize 600px 100dpi Bicubic″ saved_as ″″ saved_on ″″ parent 2 bypass 0 same_size 0 size_specific 0 breakpoint 0 n_inputs 0 n_masks 0 command ‴resize 0 onx 600 ony 338 dpi 100 memory 80901504 iunits 0 wunits 0 runits 0 resample 0 set 0 method 2 sharpen -0.75 display 1 auto_preview 1‴
end_image

image index 4 caption ″Re-Gamma 2.22″ saved_as ″″ saved_on ″″ parent 3 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴gamma_adjust 0 gray 0 rgamma 0.4500 ggamma 0.4500 bgamma 0.4500 amount 1 -1 0 0 ″Amount: ″ ″Mask″ display 1 sync_scroll 1 auto_preview 1‴
end_image

image index 5 caption ″Sharpen″ saved_as ″″ saved_on ″″ parent 4 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 0 n_masks 1 command ‴sharpen 0 kernel 0 maxovershoot 0.0667 maxundershoot 0.1000 threshold 2 strength 1.2500 amount 0.8750 -1 0 0 ″Amount: ″ ″Mask″ display 2 sync_scroll 1 auto_preview 1‴
end_image

image index 11 caption ″50%Blend Imgs 5 & 10″ saved_as ″″ saved_on ″″ parent 5 bypass 0 same_size 1 size_specific 0 breakpoint 0 n_inputs 1 n_masks 2 command ‴composite 0 operation 0 alignment 0 nalign 0 label 1 overlay_color ffffff overlay_amount 0.5 -1 0 0 ″Overlay Amount:″ ″Overlay Mask″ amount 1 -1 0 0 ″Amount:″ ″Base Mask″ display 2 sync_scroll 1 auto_preview 1 ‴
input base_image 11 input_number 0 index 10 caption ″Overlay″
end_image

end

------------------------------------------------------------------------------------------------------
The resulting image whose original size was 4896x2754 pixels:
5-DSCF2121_16x9r v1_600px.jpg
5-DSCF2121_16x9r v1_600px.jpg (77.36 KiB) Viewed 1845 times
Compare imgs 4 (gamma corrected) and 9 (no correction) to see the nuance.

The script does a 50%Blend of the sharpened two versions. Adjust the Blend to preference and image content.

Edit the Resize transforms for differing down-size then 600px wide, 100dpi, and Bicubic resampling.

Ask if there are questions... ...have fun exploring and learning PWP8!!!

...den...
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Gamma Corrected Down-sizing -- just 4 fun!

Post by jsachs »

First, a gamma 1.0 image should be much lighter than a gamma 2.2 image, so I think you are correcting in the wrong direction. I tried switching the gamma corrections and got the same result however. To avoid posterizing the image, you do need to do this on 16-bit images.

The main difference I see is that the gamma corrected version has slightly lower contrast. I'm not sure exactly why this should happen -- it does not seem to result from the de-gamma/re-gamma steps as I tried that without resampling and the results were visually indistinguishable.
Jonathan Sachs
Digital Light & Color
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 Corrected Down-sizing -- just 4 fun!

Post by den »

...
The process is really applying an inverse gamma to luminance [which darkens], resizing, then applying gamma again [which lightens]. The difference is most likely due: (1) which Resampling method is used and (2) because the image luminance is linear, neighboring pixels do not have as great of a change in gradient as they do when at normal gamma.

This is the way I envision the process...

...den...
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 Corrected Down-sizing -- just 4 fun!

Post by den »

...
Reference: "Gamma error in picture scaling": http://www.ericbrasseur.org/gamma.html?i=1

The above is a rather exhaustive discussion regarding the suggested workflow.

Use the following suggested test image:
gamma-1.0-or-2.2.png
gamma-1.0-or-2.2.png (4.59 KiB) Viewed 1820 times


in the OP script, changing the Resize setting from 600 to a 256 pixel width [half size, 2:1] in both branches.

The result should be similar to:
Rules v1 600px-1.jpg
Rules v1 600px-1.jpg (56.27 KiB) Viewed 1820 times

Have fun studying!!! Or just have faith in the suggested script.

...den...
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 Corrected Down-sizing -- just 4 fun!

Post by den »

...
Reference1: https://www.cambridgeincolour.com/tuto ... ection.htm

Need to determine which gamma is being discussed: image, display, and/or system

Reference2: https://color.viewsonic.com/explore/con ... mma_4.html

An image gamma=1.00 is indeed light.

A brightening 2.2 gamma: 1) Gamma Adjust: has a 0.45 gamma factor setting or 2) RGB Brightness Curve has a gamma curve control point at (22%,50%) or [56,128]

A darkening 2.2 gamma: 1) Gamma Adjust: has a 2.2 gamma factor setting or 2) RGB Brightness Curve has a gamma curve control point at (50%,22%) or [128,56]

A displayed image will have system gamma of a straight diagonal curve [0,0] [100,100] and its image gamma will be a gamma curve = [0,0] [22,50] [100,100]

To temporarily create linear image data, a darkening 2.2 gamma [an inverse curve of its original gamma] needs to be applied making the image appear darker as it is displayed by the system.

The object of Gamma Correction for Re-Scaling is to perform the Re-Sampling algorithms on linear image RGB data.

...den...
P.S. Evaluate the suggested test image with tongue in cheek. Most test images can be biased to show what is being put forward. The most important thing is: Is a normal image improved sufficiently to warrant consideration? Hence, the Script's last transformation is a blend for 0%, 1->99%, or 100% correction adjusted to meet preference and image content.
Locked