Page 1 of 1

Gaussian blur slow (and different) compared to Photoshop CC

Posted: 2014-07-11T12:09:22-07:00
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?

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

Posted: 2014-07-11T14:05:17-07:00
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.

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

Posted: 2014-07-11T15:16:07-07:00
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

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

Posted: 2014-07-11T17:17:34-07:00
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.

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

Posted: 2014-07-15T10:19:28-07:00
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.