Gaussian blur slow (and different) compared to Photoshop CC

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jamespharvey
Posts: 2
Joined: 2014-07-08T22:47:10-07:00
Authentication code: 6789

Gaussian blur slow (and different) compared to Photoshop CC

Post by jamespharvey »

In Photoshop CC, I can take a 200x3210px image and perform a gaussian blur telling Photoshop radius 200pixels, and it's finished very quickly (less than a second.)

If I use -gaussian-blur 200, it takes about 100 seconds. And, the result is much less blurred than Photoshop's.

If I want to duplicate Photoshop CC's blur, what radius and sigma should I be using for ImageMagick? (Photoshop doesn't have a second argument for sigma.) I'm guessing ImageMagick's "radius" argument must be different than Photoshop's "radius" argument. Or, I'm guessing ImageMagick might be performing a more accurate gaussian blur because it's taking so much longer. If so, how can I achieve a similar quality result to Photoshop's on the much faster timeframe?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gaussian blur slow (and different) compared to Photoshop

Post by fmw42 »

You would have to test this, but I believe that PS radius is either the same as IM sigma or about 2*sigma+1. It is not clear how they do the blur so fast. In IM you can use -blur, which does a 2-pass gaussian blur, much faster than -gaussian-blur.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gaussian blur slow (and different) compared to Photoshop

Post by snibgo »

"-blur" is much faster than "-gaussian-blur". (Eg 0.8s versus 17s for "-blur 0x60" on a 200x3000 image.)

For massive blurs like this, you might also consider a resize blur, eg:

Code: Select all

convert r.png -resize "1x10^!" -resize "200x3000^!" b2.png
which takes 0.12s
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gaussian blur slow (and different) compared to Photoshop

Post by fmw42 »

snibgo has a good idea. Perhaps this will be more of a gaussian blur.

Code: Select all

convert image -filter gaussian -resize 2x2% -resize WxH! result
where WxH is the input image width and height. You can adjust the 2x2% as desired to give more or less blurring.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gaussian blur slow (and different) compared to Photoshop

Post by fmw42 »

I have a method that seems to work reasonably well with a speed up of at least 64x. (For 20<sigma<50, the speed ranges from 220x to 450x for a 320x240 image. For a sigma=100, the speed up is 400x. For a sigma=200, the speed up is 210x).

Perhaps Photoshop does something similar.

Basically for blur sigmas greater than or equal to 20, resize by 1/8 (12.5%), apply the gaussian blur, then resize back to original size. For smaller blur sigmas, resize in proportion to the sigma value. See examples at my tidbits web site http://www.fmwconcepts.com/imagemagick/ ... fast_gblur

Code: Select all

convert image -resize 12.5x12.5% -gaussian-blur 0x50 -resize WxH! result
where WxH is the dimension of the original input image.
Post Reply