Widespread gamma error in image scaling algorithms (2007)
4p8.com
4p8.com
1. People writing image scaling libraries are big on speed. Many, like libswscale, are intended for realtime video playback on systems without graphics overlay acceleration. They contain truckloads of shortcuts to cheat wherever possible in the name of performance.
2. A "correct" method requires one of two things:
A. Performing one LUT per input pixel to the tapfilter, plus one LUT per output pixel (see http://news.ycombinator.com/item?id=1142084). This completely eliminates any possibility of SIMD. Other LUT schemes are also possible, like LUT[pixelX][pixelY].
B. Converting the entire image to linear 16-bit colorspace internally, then converting it back. This adds a slow preprocessing (and postprocessing) step and halves the speed of image processing.
Since both have huge speed impacts, most people writing graphics libraries don't like to do them.
Oh, and standard GPU-accelerated overlays can't really do either of these.
Python Image Library does gamma correct rescale by default. I did not realize this until I wrote my own implementation. I thought it would be several times slower than the built in, but it was only 3% slower. Boy was I surprised when I figured out why.
Then here's a simpler explanation:
We need to blend pixel values X and Y.
Normal image-scaling algorithms perform the operation (X+Y)/2, because this is fast.
However, the correct operation is ToNonLinear((ToLinear(X)+ToLinear(Y))/2), because X and Y represent a nonlinear scale, similar to how adding a 60db and 60db sound doesn't result in a 120db sound.
I almost wish gamma was a more obvious encoding process, like gzipping a file, rather than a simple function. That would save a lot of conceptual pain.
Rescaling and in general resampling is a lot simpler. These days it's pretty inexcusable not to do it in linear space. Here's my own exploration of that problem from a couple of years back:
http://petewarden.typepad.com/searchbrowser/2008/08/why-font...
Compositing and interpolating should definitely be done in linear space though.
Nonsense. When you defocus a camera, you get an effect that's comparable with a gaussian blur performed in linear space. Blurring is a well-understood operation that's existed for a long time in the analog world, before we ever did any digital processing.
A real lens blur doesn’t look much like a gaussian blur for someone who is familiar with both and paying attention.
For explanation, see for instance http://en.wikipedia.org/wiki/Bokeh
Human visual response to color is also nonlocal, which has an array of interesting effects.
Pretty sure GIMP’s main goal is to just do what Photoshop does.
Some RAW formats are 14 and some 12. High-end Hasseblads are 16. It is not unlikely that future sensors will go beyond 16 bit. Therefore it makes sense to design the workflow around 32-bit processing. Otherwise you are stuck re-architecting your entire workflow. Witness the number of Photoshop filters which only work at 8-bit.
(As for scaling in particular: many plugins already exist using better methods than bicubic interpolation, and avoiding problems like the lack of gamma correction, etc.)
But I'm not a graphics designer or whatever