Monday, March 22, 2010

Photoshop Blur function

Hi,



Does anyone how the Blur and Gaussian blur filter are implemented (I mean what is the mathematical calculation for each pixel). In particular what exactly is the radius in the Gaussian blur and how is it used in the calculation.

Or do you know where can I find this information?



Many thanks,

Son
Photoshop Blur function
Take a look at http://en.wikipedia.org/wiki/Gaussian_blur



Mike
Photoshop Blur function
There are /many/ possibilities to do it..



If you look to photoshops implementation then there are several remarkable facts:



The filter is very fast. It doesnt slow down with increasing radius.

From this it can be concluded that photoshops implementation doesnt use classic point by point convolution.



Photoshop does a tiled preview. From this it can be concluded that photoshop uses a finite impulse response filter.



A triple or quad boxfilter comes into my mind, because this combines all these properties and gives -for photographic purposes- a good approximation for gauss.

If you do the box filter twice in horizontal, twice in vertical angle, then reduce radius and do it twice in 45 degree angle and twice in 315 degree angle you get almost perfect circular isotropy, dont know if photoshop does that.

3 or 4 passes of a box filter aren't nearly good enough.



And Photoshop's implementation does slow down somewhat with larger radius.

Here is the frequency responce for gauss and quad box filter in comparison:



http://www.hphsite.de/dcamnoise/quad-boxfilter.png



And here is the relative error:



http://www.hphsite.de/dcamnoise/quad-box-error.png



The errors caused by nonlinear colorspaces are much larger ;-)



I dont doubt what you say, you should know it better, just wanted to demonstrate the investigations I made onto this matter.

Anyway, I dont know how photoshop does it so fast.



Maybe it can be done even faster and I made a new invention:



http://www.hphsite.de/dcamnoise/blur-experiment.png

You need a lot more tests to verify that it's close to a true gaussian.



Try not scaling the images, copy one layer to the other image, set the blend mode to difference, then add a levels layer above that so you can make the differences visible.



And try a more complex image, Even a black-white edge would give you more info, but something like a 64-192 edge would be better, so you can see overshoots, quantization lossses, etc,

Hi Chris,



Thats what I found out using 32 bit mode:

http://www.hphsite.de/dcamnoise/photoshop-gauss.png

So your approach has octagonal symmetry.

And I may need to do some more checking on Photoshop's 32 bit GBlur.

Hi Chris,



I did not want to blame photoshop.

Photoshops gBlur is perfectly ok.

The examples have Exposure +20, that means amplification of ca. 1000000.

Under these conditions each filter will show up some errors (and artifacts which tell something about the algorithm) because it is impossible to make a 100% perfect gaussfilter with diskrete pixels.



The filter always has errors and in a tradeof one can choose between curve accuracy, speed and isotropy.



Photoshop is not to blame the gfilter is very fast and very usable.

I know several image editors and photoshops implementation is the best I know about.

However, possibly the idea of an octagonal kernel can give some improvement at zero costs, thats what I wanted to show.



Peter

Hey, I try not to take it for granted that Photoshop's filters are perfect.



And if you can see an error, I haven't got it quite right yet.

Although, you are close to the quantization limits on single precision values...



I'll take a look at your octagonal approach.

No comments:

Post a Comment