Archived

This topic is now archived and is closed to further replies.

Crispy

Uhm - I don't get this (digital filters: lowpass -> highpass)

Recommended Posts

Steven W. Smith's The Scientist and Engineer's Guide to DSP clearly states (vol.2, p 272): to convert a lowpass filter kernel to a highpass filter kernel "first, change the sign of each sample in the filter kernel. Second, add one to the sample at the center of symmetry ". While the above works, it only works very vaguely. The closest I have got to a true spectral inversion (lowpass->highpass conversion) is through: k[M / 2] = -k[M / 2] * 0.38 + 1.0f , which is pretty darn dissimilar to k[M / 2] += 1.0f as suggested by Smith, IMO. In this case all values in k have already been negated, so the negation in the above formula (the one in bold) basically undoes that. The above is a rough approximation I achieved through testing that, at least on a visible level, inverts the entire spectrum rather nicely. However, the way Smith describes it, doesn't work. Can anyone elaborate on this a little?

"Finishing in second place, simply means you are the first loser." - PouyaCat
 
[edited by - crispy on March 19, 2004 9:55:27 AM]

Share this post


Link to post
Share on other sites
What Smith says is what works for me, and it's a near perfect inversion of the frequency response (at least as perfect as you can get with a limited number of filter taps).

To explain what he says, think of it like this. You have a lowpass filter whose impulse response is hlp(n), and you want to convert it to a highpass with the same cutoff frequency. The frequency response of the lowpass filter is then Hlp( ω ). The corresponding highpass filter is Hhp( ω )=1-Hlp( ω ).

To get the impulse response of the highpass filter, just take the inverse fourier transform of the expression, and we get hhp(n)=δ(n)-hlp(n), where δ(n) is the dirac impulse.

This assumes the sum of the filter coefficients are 1, or in other words, the gain is 0 dB is the passband. If you don't meet this requirement, you have to modify the equation slightly.

The gain in the lowest frequencies of the lowpass filter is equal to the sum of all filter coeficients, and to invert the filter, you have to modify the equations to

Hhp( ω )=α-Hlp( ω )
hhp(n)=αδ(n)-hlp(n)

where α is the sum of all filter coeficients for the lowpass filter.


[edited by - Brother Bob on March 19, 2004 10:29:32 AM]

Share this post


Link to post
Share on other sites
Thanks a lot Bob! I was doing two things wrong:

1) I didn't normalize my filter (thanks for hinting that)
2) k[M / 2] doesn't need to be negated before 1 is added (I had to re-negate it; Smith says each sample in the kernel should be negated)

Works like a charm now!

edit: (striketrhough) - I'm an idiot - this stuff can mess you up on the first run. Anyway, it appears I wasn't summing everything I needed for the normalization. Should learn to trust books more...




"Finishing in second place, simply means you are the first loser." - PouyaCat



[edited by - crispy on March 19, 2004 11:23:26 AM]

Share this post


Link to post
Share on other sites