Your scaling software SUCKS

This post is not audio-related, but it's about an issue that has seriously concerned me lately, and I think everyone should be aware of it, because it affects anyone who reads this.

GIMP - Linear interpolation
Linear interpolation, no gamma correction
GIMP - "NoHalo" interpolation
Cubic interpolation, no gamma correction

Original scaling test image by Jonas Berlin

The scaling test image is designed to showcase fundamental artifacts caused by different scaling techniques and the lack of gamma correction.

GIMP - "NoHalo" interpolation
Lanczos interpolation, no gamma correction
GIMP - Cubic interpolation
Cubic interpolation, no gamma correction
GIMP - Linear interpolation
Linear interpolation, no gamma correction

Earth's city lights image by NASA  (smaller, 31mb land_lights_16384.png available locally)

The 134-megapixel city lights image, which has so many small, bright spots, emphasizes how idiotic it is to ignore the fact that gamma correction is mandatory in image processing. Your software produces an image that literally lies to you about how lit the earth's cities are, because the developers ignore a basic rule.

Software that allows image scaling but doesn't allow to scale with gamma correction is broken by design. It's a fundamental principle in image processing, that has been used by hardware manufacturers for many years. Amazingly, almost all image and video editing software completely ignores it.

I've tested mainly downscaling, with many different kinds of images, and noticed severe issues with many of them. The gamma-corrected result has always come out on top, regardless of whether there were glaring [sic] issues or not. The image always looks more like the original. Some problems caused by the lack of gamma correction are bright, contrasting lines losing brightness when downscaled, vertical or horizontal structures looking too smeared, eyes becoming dull, and many other annoying and unnatural-looking things. Of course, in many cases, the effects of the lack of gamma correction are not immediately clear or visible at all, but when they are, it sucks. Yes, all these years, you've been doing it wrong.

See some more, interesting gamma correction examples on ImageWorsener's gamma correction page.

Gamma-related issues are not limited to scaling. Rotation, smoothing, inverting, grayscale conversion and various other functions can look wrong or bad when the software doesn't do gamma correction.

Lots of interesting information and examples, and a list of programs that scale images properly are on Eric Brasseur's excellent "Gamma error in picture scaling" site. A few corrections and things that aren't mentioned there yet:

IrfanView does not do gamma correction properly. Maybe it did in earlier versions, but current versions don't.

madVR, an essential, high quality DirectShow video renderer, can downscale with gamma correction ("scale in linear light" option), but can't upscale with gamma correction, so some things will inevitably look bad, such as the extreme scaling test image.

GIMP, since version 2.9 (development snapshots), is an editor that scales images properly. GIMP's "NoHalo" interpolation is very good as it gives a very accurate and natural-looking image with enough sharpness and unnoticeable ringing / halos. Compared to an intepolation type it's often visually similar to - 2-tap Blackman-Harris intepolation (available in ImageWorsener, which also does gamma correction, using -filter blackman2), the halos it creates are a bit less pronounced, but with certain pictures, NoHalo can be too aggressive and remove too much detail (things like text being thinned-out too much and therefore "erased"), so plain 2-tap Blackman interpolation is generally a better choice, but 2-tap Lanczos (-filter lanczos2 in ImageWorsener) is the best. The main problem with the NoHalo interpolation, at least as of this writing, is that it's amazingly, horribly slow, which is a big issue with very large images.

No comments:

Post a Comment