GNOME Bugzilla – Bug 158123
convolve tool (others too?) ignores gamma
Last modified: 2004-12-22 21:47:04 UTC
Start with an image of 1-pixel-wide black-and-white horizontal stripes. (do not use a checkerboard or vertical stripes unless you have an all-digital video system) Select the "convolve" tool. Blur a decent-sized patch of the image. Now, stand back from the monitor enough so that you don't see the individual lines. Notice how the blurred patch is darker than the rest of the screen. It should not be darker. Nearly all image manipulation operations need to be done on gamma 1.0 data to be correct. This includes scaling, rotation, blending via alpha channel, and so on. Failure to work in the linear-light space (gamma==1.0) leads to errors, mostly involving images that get too dark in spots. It can also lead to color changes. When you fix this, please remember that the sRGB gamma curve includes a linear portion near black. Also, watch the rounding direction.
I'm sure you can find the conversions elsewhere, but just in case you don't have them handy: unsigned r,g,b; double R,G,B; // linear to sRGB R = (R<=0.00304) ? 12.92*R : 1.055*pow(R,1.0/2.4)-0.055; G = (G<=0.00304) ? 12.92*G : 1.055*pow(G,1.0/2.4)-0.055; B = (B<=0.00304) ? 12.92*B : 1.055*pow(B,1.0/2.4)-0.055; // float-to-int assignment will round down, hence the .9999 r = R * 255.9999; g = G * 255.9999; b = B * 255.9999; // sRGB to linear R = r / 255.0; G = g / 255.0; B = b / 255.0; R = (R<=0.03928) ? R/12.92 : pow((R+0.055)/1.055,2.4); G = (G<=0.03928) ? G/12.92 : pow((G+0.055)/1.055,2.4); B = (B<=0.03928) ? B/12.92 : pow((B+0.055)/1.055,2.4);
GIMP completely ignores gamma and always works with gamma 1.0. Thus your bug report doesn't make much sense. There might be a problem with the convolve tool but it is certainly not related to any gamma settings.
This problem is not reproducible if you gamma correct your display. You can for example do so using the Gamma display filter. IMHO the tool is doing the right thing here. The only problem is lack of color management, most particulary lack of gamma correction in the display. *** This bug has been marked as a duplicate of 38649 ***
I'm working on a standard (sRGB gamma) display with an unmodified GIMP. When I load a *.pnm file (gamma according to PNM spec, which matches sRGB), it appears correct. Thus, I conclude that my setup is correct. If I were to change my GIMP settings to some non-standard value, properly-encoded images would no longer display as they should. So, out-of-the-box behavior on normal hardware is incorrect. It is certainly possible to fix this problem by declaring that GIMP always works with gamma 1.0, but then the file loader plug-ins would all need to be fixed and the out-of-the-box display gamma setting would need to change. Also, image defects would appear caused by the use of 8-bit channels with gamma 1.0 -- you'd need 10-bit or even 12-bit to make up for the loss. (might as well consider "float" then) Not that I mind that solution. I actually like it, but it spells the end of 8-bit channels for internal computation. I have heard that this is not a direction that the GIMP will be going in, but maybe things have changed.