The filter impulse response is [1/9 1/9 1/9;1/9 1/9 1/9;1/9 1/9 1/9]. how do i determine whether it is an Low pass filter or a high pass filter. If this is a low pass filter how do i convert it to a high pass filter or the opposite.
We assume 2 modes 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] $.
The other answer gave a rule of thumb to determine if a filter is low pass or high pass.
A simple way to convert a low pass to high pass for an even length filter is to multiply every other coefficient term by -1. The coefficients of this filter are orthogonal to the original filter.
The sum of coefficients are now zero.