# Are there any quick way to tell if a kernel is a high-pass filter?

Im new in this image processing field so please be gentle with terminology, i have a kernel of 3x3 and i want some way in order to test if its a high pass filter or not

• How about applying the two dimensional Discrete Fourier Transform to it and then looking at the spectrum (?)
– A_A
Commented Jun 8, 2018 at 13:12
• Can you please elaborate on "looking at the spectrm"? im really new at this, thanks Commented Jun 11, 2018 at 8:30

Suppose that you have the filter's impulse response in some $h$ which is of dimensions $N_h^2$. Here is an example for $N_h = 5$, a very simple smoothing mask:

$$h = \begin{matrix} 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1\end{matrix}$$

A smoothing mask is also known as a low pass filter and its effect is to suppress the information found in the high frequencies of an image (the "details"). Therefore, the effect of a "low pass filter" is to blur the image.

While there are many different ways to produce a low pass filter, the archetypal low pass filter looks like this

Therefore, if we wanted to determine what sort of filter does $h$ represent, we would have to look at its Frequency Response. The primary tool that allows us to look at the frequency response of any given mask is the two dimensional Discrete Fourier Transform.

The magnitude spectrum of the 2D DFT for the particular $h$ that I wrote above looks like this:

To interpret this diagram, you have to understand that, by convention, we take the low frequencies to be associated with the locations that are close to the middle of the image and the high frequencies to be associated with the locations in the periphery of the image.

This frequency response seems to be favouring low frequencies (lobe in the middle of the image) over high frequencies, therefore it is a low pass filter.

$$h_2 = \begin{matrix} 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & -24 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1\end{matrix}$$

Has this frequency response:

Which as you can see seems to be doing the opposite, by favouring frequencies at the periphery of the image over frequencies towards the middle of the image.

For more information on how to obtain similar plots of frequency responses, please see fft2, fftshift, abs and surf.

Hope this helps.

• @LaughingMan Glad to hear you found it helpful, you can upvote or accept the answer, from the controls on the left of the answer box, which will stop the question from circulating the board as unanswered.
– A_A
Commented Jun 12, 2018 at 11:07
• I think it is not clear what you are reffering to when you say we take the low frequencies to be associated with the locations that are close to the middle of the image. A low pass filter smootsh highly textured areas containing many edge and color changes while keeping large uniform zones and smooth color gradients. Your are right that low frequences are located at the magnitude spectrum middle but not at the image middle. This paragraph is just a little bit confusing so! Commented Jun 14, 2018 at 14:59
1. Proper way: do a Fourier transform and look at the magnitude of the result
2. Quick and dirty: take the sum of all all elements. If it's zero or small compared to the absolute sum, it has some high pass-ness to it.
• One might also be able to deduce it by converting the filter to continues time, using the tustin method for example, and look at its poles and zeros. Commented Jun 9, 2018 at 11:06
• Can you please elaborate on "look at the magnitude of the result" part? thanks :D Commented Jun 11, 2018 at 8:30