Jump to content

Photoshop High Pass filter, what does it do actually?


Recommended Posts

As I'm not using PhotoShop, but GIMP (in Linux) I would like to know

what does PhotoShop's High Pass filter do. Is there a way to replicate

the effect with a convolution matrix?

 

For example, if I choose a radius of 10 in PhotoShop, what would be

the equivalent convolution matrix? Is 3x3 or 5x5 matrix sufficent?

 

What I am after, is high pass sharpening in GIMP of course...

 

Thanks,

Olli Salonen

Link to comment
Share on other sites

<p>Ok, I found a partial answer through experiments. Photoshops high pass filter uses the following convolution matrix (or at least very similar):</p>

 

<pre>

-1 0 0 0 -1

0 -1 0 -1 0

0 0 8 0 0

0 -1 0 -1 0

-1 0 0 0 -1

</pre>

 

<p>This is of course for a high pass filter with radius 2. There seems to be a little more noise in the image, when convolution matrix is used, so my reasoning is probably not perfect or PS uses some kind of noise reduction.</p>

 

<p>But THE problem is: how on earth can I use a 21x21 convolution matrix?! Could this be avoided with some math?</p>

Link to comment
Share on other sites

I high pass filter essentially extracts high frequency detail while a blur (low pass) filter removes high frequency detail. Hence some high pass filtering methods can be created by subtracting a blurred version of an image from the original and adding an offset (127) to center the result in the interval [0,255].

 

For saving CPU time I would suggest exploring separable blurs like the Gaussian blur so that you can do two passes with a 1-D kernel rather than a single pass with a 2-D kernel. This moves your computation into O(n) time rather than O(n^2) time where n is your radius.

 

Explore what you can create and remember that most 2-D kernels are not separable.

 

I should note that this is roughly the first half of how you calculate the Unsharp Mask filter. Albeit, I have only looked closely enough at Photoshops implementation to know that their underlying blur is not the Gaussian Blur as they have a much stronger edge response.

 

my $0.02,

 

Sean

Link to comment
Share on other sites

  • 4 months later...

yep the matrix is -1 on the diagonales and n in the middle(where n is the radius), as of non int radius, it's just a different weight for the n+1 coefficient.

 

now as to make it faster i doubt you can, but it's still just n+1 addition/substractions per pixel, that's not much compared to a full matrix

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...