Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Gamma correction
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Scaling and blending === ''Generally,'' operations on pixel values should be performed in "linear light" (gamma 1). Eric Brasseur discusses the issue at length and provides test images.<ref>{{cite web |last1=Brasseur|first1=Eric |title=Gamma error in picture scaling|url=http://www.ericbrasseur.org/gamma.html|access-date=22 March 2020|date=August 2007|quote=Technically speaking, the problem is that "the computations are performed as if the scale of brightnesses was linear while in fact it is a power scale." In mathematical terms: "a gamma of 1.0 is assumed while it is 2.2." Lots of filters, plug-ins and scripts make the same error.}}</ref> They serve to point out a widespread problem: Many programs perform scaling in a color space with gamma, instead of a physically correct linear space. The test images are constructed so as to have a drastically different appearance when downsampled incorrectly. Jonas Berlin has created a "your scaling software sucks/rules" image based on this principle.<ref>{{cite web|last1=Brasseur|first1=Eric|title=Gamma error in picture scaling, Acknowledgements|url=http://www.ericbrasseur.org/gamma.html#acknowledgments|quote=Jonas Berlin sent this image. Scale it down 1:2 with your software...}}</ref> In addition to scaling, the problem also applies to other forms of [[Resampling (bitmap)|downsampling]] (scaling down), such as [[chroma subsampling]] in [[JPEG]]'s gamma-enabled [[Y′CbCr]].<ref>{{cite journal |last1=Chan |first1=Glenn |title=Toward Better Chroma Subsampling: Recipient of the 2007 SMPTE Student Paper Award |journal=SMPTE Motion Imaging Journal |date=May 2008 |volume=117 |issue=4 |pages=39–45 |doi=10.5594/J15100 |url=http://www.glennchan.info/articles/technical/chroma/chroma1.htm|doi-access=free }}</ref> [[WebP]] solves this problem by calculating the chroma averages in linear space then converting back to a gamma-enabled space; an iterative solution is used for larger images. The same ''sharp YUV'' (formerly ''smart YUV'') code is used in sjpeg<!--[https://github.com/webmproject/sjpeg]?--> and optionally in [[AVIF]]. Kornelski provides a simpler approximation by luma-based weighted average.<ref>{{cite web |title=Gamma-correct chroma subsampling · Issue #193 · mozilla/mozjpeg |url=https://github.com/mozilla/mozjpeg/issues/193 |website=GitHub |language=en}}</ref> [[Alpha compositing]], [[color gradient]]s, and 3D rendering are also affected by this issue.<ref>Archived at [https://ghostarchive.org/varchive/youtube/20211211/LKnqECcg6Gw Ghostarchive]{{cbignore}} and the [https://web.archive.org/web/20150321235204/https://www.youtube.com/watch?v=LKnqECcg6Gw Wayback Machine]{{cbignore}}: {{cite web|url=https://www.youtube.com/watch?v=LKnqECcg6Gw|title=Computer Color is Broken|author=Minute Physics|date=March 20, 2015|website=[[YouTube]]}}{{cbignore}}</ref><ref>{{cite web |title=What every coder should know about gamma |url=https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/ |last=Novak|first=John|date=September 21, 2016}}</ref> Paradoxically, when upsampling (scaling up) an image, the result processed in a "wrong" (non-physical) gamma color space is often more aesthetically pleasing.<ref>{{cite web|title=Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?|author=Nicolas Robidoux|url=https://legacy.imagemagick.org/discourse-server/viewtopic.php?p=89754#p89754|website=ImageMagick discourse server|quote=Generally, the linear light colour spaces (linear RGB and XYZ) produce exaggerated dark halos, and the "perceptual" colour spaces (sRGB, LAB, LUV) produce exaggerated light halos. If you think about it for a minute, this makes complete sense, because the perceptual colour spaces pack lots of bits at the darker end of the intensity spectrum, and "hollow out" the lighter end, so as to mimick the HVS (Human Visual System). So, 1 unit of dark overshoot gets you less "far" in sRGB than in linear RGB, but 1 unit of light overshoot gets you less "far" in linear RGB than sRGB.}}</ref> This is because resampling filters with negative lobes like [[Mitchell-Netravali filters|Mitchell–Netravali]] and [[Lanczos resampling|Lanczos]] create [[ringing artifacts]] linearly even though human perception is non-linear and better approximated by gamma. (Emulating "stepping back," which motivates downsampling in linear light (gamma=1), does not apply when upsampling.) A related method of reducing the visibility of ringing artifacts consists of using a [[Sigmoid function|sigmoidal]] light transfer function as pioneered by [[ImageMagick]] and [[GIMP]]'s LoHalo filter and adapted to video upsampling by [[Video renderer|madVR]], [[AviSynth]] and [[Mpv (media player)|Mpv]].<ref>{{cite web |title=Resizing using a Sigmoidal Colorspace|author=Anthony Thyssen |url=https://imagemagick.org/Usage/resize/#resize_sigmoidal |website=imagemagick.org |language=en |quote=A new technique has been developed in which rather than trying to resize images in a linear color space, the image is resized in a modified colorspace using the Sigmoidal Color Modifier Operator (-sigmoidal-contrast). This can reduce the clipping of extreme halo or Ringing Artefacts that may develop along very sharp edges.}}</ref><ref>{{cite web |title=GNOME/gegl: gegl-sampler-lohalo.c |url=https://github.com/GNOME/gegl/blob/master/gegl/buffer/gegl-sampler-lohalo.c|website=GitHub |language=en |quote=Sigmoidization was invented by N. Robidoux as a method of minimizing the over and undershoots that arise out of filtering with kernel with one more negative lobe. It basically consists of resampling through a colorspace in which gamut extremes are "far" from midtones.}}</ref><ref>{{cite web|title=madVR - high quality video renderer (GPU) assisted)|author=Mathias Rauen|url=https://forum.doom9.org/showthread.php?p=1595323#post1595323|website=forum.doom9.org|language=en|quote=I've now implemented your sigmoid function "stretching" and it seems to work well, from what I can see.}}</ref><ref>{{cite web|title=Dither tools|website=AviSynth wiki|url=http://avisynth.nl/index.php/Dither_tools#Dither_sigmoid_direct.2C_Dither_sigmoid_inverse|language=en|quote=Dither_sigmoid_inverse applies the inverse sigmoid curve to a clip in linear luminance in order to lessen the ringing when resizing it. Dither_sigmoid_direct converts back a clip to linear luminance. The chroma channels remain untouched.}}</ref><ref>{{cite web|title=mpv-player: options.rst|url=https://github.com/mpv-player/mpv/blob/d8c2e33a5d3840045a84cd5fa22c9c601fb1a0ae/DOCS/man/options.rst|website=GitHub|language=en|quote=When upscaling, use a sigmoidal color transform to avoid emphasizing ringing artifacts. Enabled by default. This is incompatible with and replaces --linear-upscaling. (Note that sigmoidization also requires linearization, so the LINEAR rendering step fires in both cases)}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Gamma correction
(section)
Add topic