After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 508114 - Convolution matrix plug-in biased towards darker colors
Convolution matrix plug-in biased towards darker colors
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.4.x
Other All
: Normal minor
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2008-01-08 18:21 UTC by Alexander Thomas
Modified: 2008-10-30 20:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alexander Thomas 2008-01-08 18:21:39 UTC
When creating a custom filter using the 'Generic'->'Convolution Matrix', the resulting filter has a bias toward darker colors.

A simple way to demonstrate this is to create a new small image (e.g. 100x100) and fill it with 50% gray. Draw a small white square near the top left corner of the image and a small black square near the bottom right corner. Then, make a rectangular selection whose corners are in the middle of the small squares.
Then, create this simple diffusion filter in the Convolution Matrix dialog:
1 1 1
1 0 1
1 1 1
And either use a divisor of 8, or enable 'Normalise'.
Then, apply this filter repeatedly (to get a true diffusion, you'd need to do it an infinite amount of times, but 100 times will be more than enough).

The correct image would show an equal influence of the white corner as for the dark corner, with the center pixel of the image at 50% gray.
In the output from the GIMP, though:
  http://homes.esat.kuleuven.be/~athomas/tmp/gimp_convol_bug.png
the influence of the dark corner completely overwhelms the influence of the white corner and the center pixel is at 30%. The result is the same when the squares are placed in different corners, so it is definitely an effect of intensity, not location. If I'd have to guess the cause, it's probably a rounding error or incorrect bias value somewhere.

If this sounds like an artificial test, I use this technique often to 'inpaint' missing parts in images. This bug makes GIMP useless for this.

I notice the same effect when using the 'blur' tool. Someone else has made a movie which illustrates this: http://schalken.wubbles.net/gimpblurdarkensbug2.ogg
Comment 1 Sven Neumann 2008-01-08 20:58:27 UTC
Similar bugs have been fixed in a couple of places before the 2.4 release. The Blur tool shouldn't be affected by this any longer. It's a simple rounding error due to truncation. You will find it easy to fix this by adding half of the divisor to the dividend before doing the integer division. Patches welcome.
Comment 2 Sven Neumann 2008-01-08 21:08:36 UTC
You are right, the Blur tool is also still affected.
Comment 3 Sven Neumann 2008-01-09 10:21:24 UTC
No, you aren't. The Blur tool actually does all calculations in floating-point and correctly rounds the results. I can also not reproduce any darkening with the Blur tool. Changing the summary accordingly.
Comment 4 Sven Neumann 2008-01-09 10:38:59 UTC
I've committed this fix to both branches:

2008-01-09  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/convmatrix.c (convolve_image): round the result
	of the convolution. Fixes bug #508114.