5
$\begingroup$

I am currently reading on the topics of image filtering and convolution kernels. While the process of convolution is clear to me, I do not understand, how one arrives at the statement, that a certain filter is a low or a high pass?

How can one derive that? For example, if one averages the value of a pixel respecting its surrounding pixels, does that for all pixels, then each pixel would have a value between the minimum and the maximum value of the previous image. It treads low values and high values equally, however literate often states, that it is a low pass filter.

For that specific case I found the question What is the intuition of "averaging is a low pass filter". Reading it, however didn't help me, as I seem to lack something to see how these arguments are correct and intuitive. Thus I hope, that a more mathematical approach (can be a general one), would benefit me.

$\endgroup$
3
  • $\begingroup$ You might find this question useful as well. How familiar are you with digital filters in the time domain (i.e. Simple, one dimensional filters)? $\endgroup$
    – A_A
    Sep 3, 2018 at 12:53
  • $\begingroup$ @A_A, not too familiar, I am afraid. I have a maths/computer science background, so a lot of material that is very basic to for example to electrical engineers is fairly new/strange to me at the moment :/ $\endgroup$
    – Imago
    Sep 3, 2018 at 14:08
  • $\begingroup$ @Imago You might find this helpful as well. $\endgroup$
    – datageist
    Sep 3, 2018 at 17:30

3 Answers 3

1
$\begingroup$

Welcome to DSP Community.

General

We assume 2 types of filters: LPF or HPF.

Classifying Filter Type

Usually, if it is a well planned LPF and well Planned HPF a simple test will do.
Calculate the sum of all coefficients.
The sum of the coefficients is the first element of the DFT of the signal.
It means it is the DC gain and well behaved LPF has gain of 1 and well behaved HPF have DC gain of 0.

So sum the coefficients and:

  • If the sum is $ 1 $ then this is an LPF.
  • If the sum is $ 0 $ then this is an HPF.

Pay attention that those method can't differentiate between HPF and Band Pass or between LPF and Band Stop.

The more general method is to look on its DFT Spectrum to see its behavior.

Converting Filter Type

There is very intuitive formula - ALL_PASS_FILTER = LPF_FILTER + HPF_FILTER.
It's not accurate but this is the idea.

Be more accurate in the Frequency Domain All Pass Filter is a filter which has value of 1 for any frequency.
Assuming we have LPF Filter then HPF_FILTER = ALL_PASS_FILTER - LPF_FILTER.
In the spatial domain it means $ h \left[ n \right] = \delta \left[ n \right] - l \left[ n \right] $.

Where $ \delta \left[ n \right] $ is the filter with 1 in its origin and $ 0 $ anywhere else.

In your case $ \delta \left[ n \right] = [0, 0, 0, 0, 1, 0, 0, 0, 0] $.
So the HPF Filter becomes $ h \left[ n \right] = \delta \left[ n \right] - l \left[ n \right] = [-1/9, -1/9, -1/9, -1/9, 8/9, -1/9, -1/9, -1/9, -1/9] $.

$\endgroup$
2
$\begingroup$

Whether a 2-D LSI filter is LPF, BPF, HPF etc. is decided according to its frequency response, $H(\omega_1, \omega_2)$, which is the discrete-time Fourier transform of its impulse response $h[n_1 , n_2]$

The ideal frequency selective filters are then defined as: (in all cases $-\pi< \omega < \pi$)

$$ H_{LPF}(e^{j\omega_1},e^{j\omega_2}) = \begin{cases}{1~~~,~~~|\omega_1| < \omega_{c1},|\omega_2| < \omega_{c2}, \\ 0 ~~~,~~~~\text{otherwise} }\end{cases} $$

$$ H_{HPF}(e^{j\omega_1},e^{j\omega_2}) = \begin{cases}{1~~~,~~~|\omega_1| > \omega_{c1},|\omega_2| > \omega_{c2} \\ 0 ~~~,~~~~\text{otherwise} }\end{cases} $$

$$ H_{BPF}(e^{j\omega_1},e^{j\omega_2}) = \begin{cases}{1~,~ \omega_{c1}<|\omega_1| < \omega_{c2},\omega_{d1}<|\omega_1| < \omega_{d2} \\ 0 ~,~\text{otherwise} }\end{cases} $$

It is important to re-emphasize that a frequency selective filter is mainly defined in the frequency-domain (sepcifications are given), and then its impulse response is derived in time-domain as a consequence.

Note that as other answers outlined, there are some properties of the impulse response of LTI filters, which can be used to decide whether it's an LPF or HPF in a simple manner.

$\endgroup$
2
  • $\begingroup$ I'm not sure about the history, yet I feel that Sobel or Prewitt filters were designed out of computation simplicity, more than in frequency $\endgroup$ Sep 3, 2018 at 21:33
  • 1
    $\begingroup$ I will also add this to the exception examples, thanks! @LaurentDuval $\endgroup$
    – Fat32
    Sep 3, 2018 at 21:43
1
$\begingroup$

Since the filters are linear, you can check their behavior against some images whose filtered versions are easy to compute. Multiplies are complicated, so images with only $\pm 1$ valued pixels are great (only adds in the convolution). Simple operations cannot tell you exactly what a filter is, they only give you some hints, that ought to be checked in Fourier.

The most low-pass image $L$ is constant, so all pixels are one. The corresponding value is $v_L = \sum_{m,n} h[m,n]$. If $v_L \neq 0$ (some filters can be normalized wrt energy), notably if $v_L =1$, a non-zero constant image remains non-zero. So the filter is not $0$-cut.

The most high-pass images $H$ have alternating $\pm 1$ in a quincunx scheme. The corresponding value is either $v_H = \sum_{m,n} (-1)^{m+n}h[m,n]$ or the opposite. If $v_H \neq 0$, it is not high-cut.

If $|v_L| > |v_H|$, the filter tends to better preserve low-frequencies than high ones (and conversely). If $|v_L| \approx 1$ while $v_H$ is much smaller, this hints at a low-pass behavior, especially if all $h[m,n]$ are positive. If $|v_H| \approx 1$ while $v_L$ is much smaller, this hints at a high-pass behavior, especially if $h[m,n]$ have alternating signs.

You can also check if the filter is low-pass along rows and high-pass along columns (and conversely), typical of horizontal and vertical edge filters. For that, try alternating rows (or columns) of $1$ and $-1$. This amounts to testing values $v_R = \sum_{m,n} (-1)^{n}h[m,n]$ or $v_C = \sum_{m,n} (-1)^{m}h[m,n]$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.