# filter coefficients to know high pass and low pass filter

Looked on few questions already there in dsp.stackexchange and couldn't get the direct answer. Basically I have a kernel of a gaussian separable filter.

float w[N*2+1] = {-0.00467444956f, -0.0531099625f, 0.0152470656f, 0.300147355f,  0.484779954f, 0.300147355f,  0.0152470656f, -0.0531099625f, -0.00467444956f};

float w2[N*2+1] = {-0.00899997167f, 0.0197822638f, -0.0300691985f, 0.0374629796f, 0.963647842f, 0.0374629796f, -0.0300691985f, 0.0197822638f, -0.00899997167f};


The coefficients in first first increasing and then starts decreasing.The middle point is strongest and it is close to 0.5.

In 2nd the coefficients are of alternate sign with middle being storngest close to 1.

What properties these coefficients signify? How can I relate them to high pass or low pass filter?

I am using the above kernels in the smoothening the image using Gaussian separable filter.

A quick rule-of-thumb to quickkly assess short FIR filters: if the sum of your coefficients is close to $1$, then the filter preserves the constant signals (because it will gives you the gain at frequency 0 or DC). And possibly preserves some other low-frequencies too. So it may have a low-pass behavior.

If the sum of the odd coefficients minus the even coefficients is close to zero, the filter tends to attenuate high frequencies. So it may have a high-cut behavior.

What is in between is not known but this provides you with a first approximation. Other computations tell yoou if it is somehow low-cut and high-pass.

This is the case for your first filter: sum $1$, odd-even $-0.0119$.

Adding that it is symmetric, with triangular shape (up/down), the low-pass is likely, like a weighted average with decaying weights away from the center. And this can be checked (see Figure below).

For the second one, this is more difficult: coefficients sum to $1$, and the odd/even difference is quite high ($0.77$). But if you look carefully, only one coefficient is big, the others are very small. So it looks like a unit pulse ("discrete dirac"), hence an all-pass behavior is possible, with a tiny little smoothing at high frequencies, as shown below..

But these are only rules of thumbs, which turn out correct. I can see no high-pass in your filters. If you combine then in 2D (left in Figure below), you are likely to smooth mostly in the direction of the first filter, like a $\frac{1}{4}[1\,2\,1]^T$ 3-tap Gaussian filter (right in Figure below):.added

I think the filters may be sum of a lowpass and a hightpass filter. They may use to extract some high frequency and low frequency components of a signal. For example to extract the edges of an image and smooth then simultaneously.

• but what is the criteria here with which we identify that it is high pass or low pass? – Learner Aug 19 '15 at 8:43

If you multiply the coefficients of a lowpass FIR filter by the sequence 1,-1,1,-1,1,-1, ..., (-1)^n, you end up with the coefficients of a highpass FIR filter. To demonstrate this, multiply your first set of coefficients by (-1)^n and compute the freq response of the new coefficient sequence. [‘n’ is a sequence of integers starting with zero.]

However, that is not the case with your two sets of coefficients. Both of your coefficient sequences produce lowpass filters.

ok, so i didn't check the exacte numbers, because it seems that your filter w2 was different coefficients than w1. But imagine if w2 were to be exactly as w1 but with alternating signs, so w2 = -1^n*w1.

What you have here is that, if w1 is a lowpass filter (the easy example), then w2 is the equivalent highpass filter, because when you take the Z transform, the -1^n transforms to multiplying the Z^-n in the equation to e^pi, which would shift the frequency response by pi, so what was low frequencies, now is high frequencies.

I don't have time know to do all the math in detail but hopefully it is understandable.