Gaussian blur broken in my build

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Gaussian blur broken in my build

Post by neuron » 2016-07-14T07:23:50-07:00

While testing ImageMagick on Solaris 10, I found that gaussian blur is broken.

Sample taken from your site, enlarged a bit:

Code: Select all

convert -size 1700x1000 xc:black -fill white -draw 'circle    500,500  130,500' -draw 'circle   1200,500 1570,500' -draw 'rectangle 500,130 1200,870' -fill black -draw 'circle    500,500  250,500' -draw 'circle   1200,500 1450,500' -draw 'rectangle 500,250 1200,750' -fill white -draw 'circle    600,500  400,500' -draw 'circle   1100,500 1300,500' -draw 'rectangle 600,300 1100,700' -gaussian 10x10 +matte logo_mask.png
https://ibin.co/2o2Lhd3bf6PI.png

Interestingly if I do the same, just the output is *.gif, the image looks correct

https://ibin.co/2o2LqgQQQbhH.gif

Now before I start to blame IM, I would like to see the sources. And here's the question, where is the code doing gaussian blur for png (for un-indexed pallete I guess)? It smells as more math problems similar to what I had with comparing two double numbers exactly, without epsilon...

grep --include '*.c' -ri gaussian .

shows a lot of lines...

Thank you
__
Vlad

neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Re: Gaussian blur broken in my build

Post by neuron » 2016-07-14T08:01:09-07:00

Hmm, the function seems to be AcquireKernelBuiltIn in magick/morphology.c. And it seems to generate nice gaussian values. From 0.000585 at the corner to 0.001592 in the middle. They numbers are small, but they seem to fall the further one is from center. I don't have this problem latest Solaris box which uses different compiler, so I'll compare the results there. So maybe the problem is in application of the mask...

snibgo
Posts: 12437
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gaussian blur broken in my build

Post by snibgo » 2016-07-14T09:01:22-07:00

It might be helpful if you mentioned which version of IM you are using. Also if you gave a minimal command that showed the problem.

The documentation http://www.imagemagick.org/script/comma ... ssian-blur doesn't list "-gaussian" as a valid option. It should be "-gaussian-blur".
snibgo's IM pages: im.snibgo.com

neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Re: Gaussian blur broken in my build

Post by neuron » 2016-07-15T02:12:15-07:00

Yes, that will be helpfull indeed :)

version 6.9.5-2

I have minimized the reproducible case to

broken:
convert -size 100x100 xc:black -fill white -draw 'circle 50,50 13,50' -gaussian 1x1 +matte png64:logo_mask.png
https://ibin.co/2o7sDXKWcyXA.png
ok:
convert -size 100x100 xc:black -fill white -draw 'circle 50,50 13,50' -gaussian 1x1 +matte png32:logo_mask.png
(or any other png than png64)
https://ibin.co/2o7sU5HKdyrT.png


At the moment I'm looking at ExportRGBAQuantum which seems to be the function where some sort of internal image type is converted to given bitness. And where the code takes different path for png64 and png32.

Thank you
__
Vlad

neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Re: Gaussian blur broken in my build

Post by neuron » 2016-07-15T02:13:51-07:00

Oh, and the -gaussian parameter is taken from here: http://www.imagemagick.org/Usage/advanced/#3d-logos

snibgo
Posts: 12437
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gaussian blur broken in my build

Post by snibgo » 2016-07-15T06:31:25-07:00

"-gaussian" currently works in v6. It doesn't in v7 magick, which needs "-gaussian-blur". "+matte" is also deprecated (but works in v6 and v7, for now).

Sorry, I can't reproduce the problem with IM v6.9.2-5, v6.9.3-7 or v7.0.1-4. Did you build IM yourself? If so, it may be an old libpng or something. "convert -list format" will have a line like:

Code: Select all

      PNG* PNG       rw-   Portable Network Graphics (libpng 1.6.17)
snibgo's IM pages: im.snibgo.com

neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Re: Gaussian blur broken in my build

Post by neuron » 2016-07-15T07:18:17-07:00

Yes, I have built IM myself and because of the old environment I had to make few changes. That's why I asked where the blurring actually happens instead of blaming IM :) Anyway, at the moment I think that the compiler has some problem with compiling PopShortPixel (in magick/quantum-private.h). If I put printf in the routine (making the function non-leaf) blurring start to work again...

Thanks for looking into this
__
Vlad

snibgo
Posts: 12437
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gaussian blur broken in my build

Post by snibgo » 2016-07-15T08:15:12-07:00

I think gaussian blur always goes through effect.c function GaussianBlurImageChannel().

To eliminate a couple of possibilities, you might try a build with configure options "--disable-openmp --disable-opencl". Then, gaussian blur will use MorphologyImageChannel().

I think a developer should look at this.
snibgo's IM pages: im.snibgo.com

neuron
Posts: 12
Joined: 2016-06-24T05:03:47-07:00
Authentication code: 1151

Re: Gaussian blur broken in my build

Post by neuron » 2016-07-18T03:54:03-07:00

TL;DR Case solved, thanks everyone who helped.

It turns out to be a problem with old C compiler. At the end the problem was caused by miscompiled PopShortPixel. I tried to compile with more recent Studio compiler, but it failed on magick/deprecate.h (I guess it does not like to have 'export' with multiple functions on one line).

So this is problem on my side, not on ImageMagick side. Thanks again

Post Reply