GNOME Bugzilla – Bug 592628
Scale Image adds asymmetric artifacts to image edges
Last modified: 2018-01-02 22:38:53 UTC
Create a 3×3 white image and color the center pixel black, then scale the image up to 9×9. • With Linear interpolation, a gray pixel (#e2e2e2) is present at the top left corner. • With Cubic interpolation, there are many gray pixels along the top and left edges. • With Sinc (Lanczos3) interpolation, the top and left edges are colored not-quite-white (#fefefe), while the bottom and right edges are white (#ffffff). Now create a 9×9 white image and color the center 3×3 block black, and scale the image down to 3×3. • With Linear, Cubic, or Sinc interpolation, the pixels on the top and left will be much lighter than the pixels on the bottom and right. The latter problem can be reproduced with larger images and doesn’t only happen on the edge; it suggests that the entire image is being shifted down and right by some subpixel offset. I’m using gimp 2.6.6-1ubuntu2 on Ubuntu Karmic amd64.
Created attachment 141422 [details] [review] Partial fix The first part of this bug report is easily fixed with the attached patch: there are a couple of cast of a double to int that should be changed with two calls to 'floor', the first rounds toward zero the second toward -infinity. The second requires more work. The actual code performs the decimation by initially halving repeatedly the image, but doesn't cope well with odd sizes. What you observe is the same you'd obtain if your initial image was 8x8 with the black square in the same position. Patch against 'app/paint-funcs/scale-region.c' of release 2.6.7.
What can we do to help you start using git?
Review of attachment 141422 [details] [review]: This kind of patching needs to come with test cases, otherwise we will reintroduce the original issue when fixing problems that this fix (pessimistically presumed) introduces.
Massimo, what about the patch here? Should it go into git master?
Massimo, Martin, ping
Review of attachment 141422 [details] [review]: This patch was committed to the branch gimp-2-8: commit e09233f08074212db8994bfffbca6ec3ecbefe32 Author: Massimo Valentini <mvalentini@src.gnome.org> Date: Sat Oct 13 14:56:47 2012 +0200 Bug 592628: Scale Image adds asymmetric artifacts to image edges first problem described.
Created attachment 239297 [details] Testresults with 2.8.4
(In reply to comment #7) > Created an attachment (id=239297) [details] > Testresults with 2.8.4 That pdf is wrong. When upscaling 3x3 -> 9x9 With linear interpolation the central (5th) row contains: 255 255 170 85 0 85 170 255 255 as expected. With Cubic and Lanczos the 3rd,7th rows/columns are not uniform 255 and the four corners having a different background suggest they're wrong. But the point is: when you reconstruct and resample a downsampled box signal, you don't get the box signal, you get an oscillating signal. Having chosen white and black (255,0) for the original, you are missing that values greater than 255 are approximated with 255 and values less than 0 with 0. If you repeat the experiment with light and dark gray (192,64) you'll see the typical ringing artifacts expected around hard edges.
Will this ever be fixed? I suggest we close it as OBSOLETE because that code is completely gone in master. So unless somebody has the intention of fixing it... Opinions?
Closing as OBSOLETE as I suggested 3 years ago... Nobody will ever fix this in 2.8.