possible bug -selective-blur IM 6.7.8.8 Q16

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25578
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug -selective-blur IM 6.7.8.8 Q16

Post by fmw42 » 2012-08-07T12:59:10-07:00

IM 6.7.8.8 Q16 Mac OSX Snow Leopard

-selective blur does not seem to be working after IM 6.7.7.7. In some releases, it does not finish and in others it produces no change.

Input:
Image

IM 6.7.4.10
convert makeup_before.jpg -selective-blur 0x3+20% makeup_before_sb0x3_20_im6.jpg

Image



IM 6.7.8.8
convert makeup_before.jpg -selective-blur 0x3+20% makeup_before_sb0x3_20_im.jpg

Image

User avatar
magick
Site Admin
Posts: 11066
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -selective-blur IM 6.7.8.8 Q16

Post by magick » 2012-08-07T18:14:26-07:00

We can reproduce the problem you posted and have a patch in ImageMagick 6.7.8-9 Beta. Thanks.

In regards to speed-- the reason is it thresholds on the luminance of the RGB color.  This requires removal of the gamma function for sRGB images which uses the power function.  Gamma function removal is required per Bruce Lindbloom @ http://www.brucelindbloom.com/WorkingSpaceInfo.html:
Perhaps you've learned that you can compute the luminance of an RGB color by taking 30% of its red component plus 59% of its green component plus 11% of its blue component. These weightings are often expressed in three-digit precision as 29.9% red, 58.7% green and 11.4% blue. Did you ever wonder where these weightings came from?

You can find them in the above table as the relative Y values for red, green and blue for the NTSC color model. The more precise weightings are 29.8839% red, 58.6811% green and 11.4350% blue. But it should also be obvious that the real RGB weightings depend upon the color system in use. So the "standard" weightings are incorrect for other RGB systems like sRGB or Adobe RGB (1998).

Another relevant fact is that these weightings must be made in a linear RGB space, that is, after the gamma companding function has been removed. It is very common to see the weightings applied bluntly to the companded RGB values, which is wrong.
A speed-up is upfront conversion to linear then back:
  • convert makeup_before.jpg -colorspace rgb -selective-blur 0x3+20% -colorspace sRGB makeup_blur.jpg

User avatar
fmw42
Posts: 25578
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -selective-blur IM 6.7.8.8 Q16

Post by fmw42 » 2012-08-07T20:36:49-07:00

magick wrote:We can reproduce the problem you posted and have a patch in ImageMagick 6.7.8-9 Beta. Thanks.

In regards to speed-- the reason is it thresholds on the luminance of the RGB color.  This requires removal of the gamma function for sRGB images which uses the power function.  Gamma function removal is required per Bruce Lindbloom @ http://www.brucelindbloom.com/WorkingSpaceInfo.html:

A speed-up is upfront conversion to linear then back:
  • convert makeup_before.jpg -colorspace rgb -selective-blur 0x3+20% -colorspace sRGB makeup_blur.jpg

For some versions, I found it never finished or took so long I gave up.

Nevertheless, testing with IM 6.7.6-10, where I found it worked fine, I get no significant speed difference accounting for RGB/sRGB color conversion as above, but the results are clearly not as good using color conversion vs without it.

So I think that speed is not an issue in this case at least for my small image. I think some earlier versions just had bugs and either took so long as to be impractical or did nothing as I reported above. For example when it work in 6.7.6-10, it took about 1-2 seconds either way. For versions such as 6.7.8.0, it took 57s to finish with RGB/sRGB conversion and 72s without. And the later was clearly the better result (without conversion)

User avatar
fmw42
Posts: 25578
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -selective-blur IM 6.7.8.8 Q16

Post by fmw42 » 2012-08-10T10:21:29-07:00

This is now working fast and properly in IM 6.7.8.9 Q16 Mac OSX SnowLeopard

Post Reply