DSPRelated.com
Forums

Half-Band Filter Length

Started by Randy Yates November 17, 2004
Hi comp.dsp,

Rick Lyons [lyonsnew] states that if S is the number
of taps in a half-band filter, then S+1 must be divisible
by four. 

Why?

--Randy

@BOOK{lyonsnew,
  title = "{Understanding Digital Signal Processing}",
  edition = "Second",
  author = "{Richard~G.~Lyons}",
  publisher = "Prentice Hall",
  year = "2004"}
-- 
%  Randy Yates                  % "...the answer lies within your soul
%% Fuquay-Varina, NC            %       'cause no one knows which side
%%% 919-577-9882                %                   the coin will fall."
%%%% <yates@ieee.org>           %  'Big Wheels', *Out of the Blue*, ELO
http://home.earthlink.net/~yatescr
Randy Yates wrote:
> Hi comp.dsp, > > Rick Lyons [lyonsnew] states that if S is the number > of taps in a half-band filter, then S+1 must be divisible > by four. > > Why?
So that the first and last coefficients are not zero? -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (603) 226-0404 x536 The sooner you get behind, the more time you'll have to catch up
Jim Thomas <jthomas@bittware.com> writes:

> Randy Yates wrote: >> Hi comp.dsp, >> Rick Lyons [lyonsnew] states that if S is the number >> of taps in a half-band filter, then S+1 must be divisible >> by four. Why? > > So that the first and last coefficients are not zero?
Ah - yup. Thanks Jim-meister. -- % Randy Yates % "With time with what you've learned, %% Fuquay-Varina, NC % they'll kiss the ground you walk %%% 919-577-9882 % upon." %%%% <yates@ieee.org> % '21st Century Man', *Time*, ELO http://home.earthlink.net/~yatescr

Randy Yates wrote:
> > Hi comp.dsp, > > Rick Lyons [lyonsnew] states that if S is the number > of taps in a half-band filter, then S+1 must be divisible > by four.
Hi Randy, Well, assuming "the number of taps" has a unique meaning (which it doesn't if we can merely append zeroes at the beginning or end), the reason is symmetry. In order for the magnitude response to be symmetric (or anti-symmetric) the filter length must be 4n-1 (n = some integer) and the middle coefficient will be equal to the sum of the other coefficients. Of course one needs to define a half-band filter as being symmetrical in the frequency domain for this to apply. -jim ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
jim <"N0sp"@m.sjedging@mwt.net> wrote in message news:<419b6b72$1_4@127.0.0.1>...
> Randy Yates wrote: > > > > Hi comp.dsp, > > > > Rick Lyons [lyonsnew] states that if S is the number > > of taps in a half-band filter, then S+1 must be divisible > > by four. > > Hi Randy, > > Well, assuming "the number of taps" has a unique meaning (which it > doesn't if we can merely append zeroes at the beginning or end), the > reason is symmetry. In order for the magnitude response to be symmetric > (or anti-symmetric) the filter length must be 4n-1 (n = some integer) > and the middle coefficient will be equal to the sum of the other > coefficients. Of course one needs to define a half-band filter as being > symmetrical in the frequency domain for this to apply.
I'm missing something. For n = 1 we get N= 4*1-1 = 3 nonzero taps, which is the lowest odd order of a nontrivial symmetric FIR filter. So far so good. Next, set n = 2 and get N = 4*2-1 = 7. Why is N = 5 not an admissible number of nonzero taps? It's odd and it's possible to construct an (anti)symmetric impulse response? Rune
jim wrote:
> > Randy Yates wrote: > >>Hi comp.dsp, >> >>Rick Lyons [lyonsnew] states that if S is the number >>of taps in a half-band filter, then S+1 must be divisible >>by four. > > > Hi Randy, > > Well, assuming "the number of taps" has a unique meaning (which it > doesn't if we can merely append zeroes at the beginning or end), the > reason is symmetry. In order for the magnitude response to be symmetric > (or anti-symmetric) the filter length must be 4n-1 (n = some integer) > and the middle coefficient will be equal to the sum of the other > coefficients. Of course one needs to define a half-band filter as being > symmetrical in the frequency domain for this to apply. > > -jim > > > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- > http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
It is not exactly true that the middle coefficient will be equal to the sum of the other coefficients. The sum of the coefficients is equal to magnitude response at the zero frequency and for the half-band filters the magnitude response at zero frequency is either 1-delta or 1+delta where delta is the ripple in the pass- and stopband. Of course, the filter can be scaled some other way but in this case the correspondin lowpass-highpass filter pair can be implemented as a parallel connection of G(z^2) and 1/2z^{-M}, where M is the half the filter order and the zero-phase response H(omega) satisfies H(omega)+H(pi-omega)=1. % Matlab code M = 21; % must be odd passbandEdge = 0.4; h = []; h((M+1):M:(2*M+1)) = [0.5 0]; [g, ripple] = remez(M, [0 2*passbandEdge 1 1], ... [0.5 0.5 0 0], {128}) h(1:2:end) = g(1:end); [H, w] = freqz(h, 1, 2^10, 2); iPassband = find(w <= passbandEdge); plot(w(iPassband), abs(H(iPassband))) disp(['ripple = ' num2str(ripple) ' = ' num2str(abs(1-abs(H(1)))) ... ' = ' num2str(abs(1-sum(h)))]) -- Juha

Juha wrote:

> It is not exactly true that the middle coefficient will be equal to the > sum of the other coefficients. The sum of the coefficients is equal to > magnitude response at the zero frequency and for the half-band filters > the magnitude response at zero frequency is either 1-delta or 1+delta > where delta is the ripple in the pass- and stopband. > > Of course, the filter can be scaled some other way but in this case the > correspondin lowpass-highpass filter pair can be implemented as a
Yes, point is valid. It comes down to how you choose to define things. We would both agree that if the DC gain of the filter is 1.0 then the absolute sum of the side coefficients is 0.5 and the middle coefficient is also 0.5. Now if you simply scale the filter one could argue that is no different than using the same filter and scaling the output. Or... you could argue as you do, that scaling will change the symmetry of the filter. If we would agree that regardless of the scaling the perfect balance between the pass band and stop band must be maintained then the center tap must always be 0.5. -jim
> parallel connection of G(z^2) and 1/2z^{-M}, where M is the half the > filter order and the zero-phase response H(omega) satisfies > H(omega)+H(pi-omega)=1. > > % Matlab code > M = 21; % must be odd > passbandEdge = 0.4; h = []; > h((M+1):M:(2*M+1)) = [0.5 0]; > [g, ripple] = remez(M, [0 2*passbandEdge 1 1], ... > [0.5 0.5 0 0], {128}) > > h(1:2:end) = g(1:end); > [H, w] = freqz(h, 1, 2^10, 2); > iPassband = find(w <= passbandEdge); > plot(w(iPassband), abs(H(iPassband))) > > disp(['ripple = ' num2str(ripple) ' = ' num2str(abs(1-abs(H(1)))) ... > ' = ' num2str(abs(1-sum(h)))]) > > -- > Juha
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

Rune Allnor wrote:
> > jim <"N0sp"@m.sjedging@mwt.net> wrote in message news:<419b6b72$1_4@127.0.0.1>... > > Randy Yates wrote: > > > > > > Hi comp.dsp, > > > > > > Rick Lyons [lyonsnew] states that if S is the number > > > of taps in a half-band filter, then S+1 must be divisible > > > by four. > > > > Hi Randy, > > > > Well, assuming "the number of taps" has a unique meaning (which it > > doesn't if we can merely append zeroes at the beginning or end), the > > reason is symmetry. In order for the magnitude response to be symmetric > > (or anti-symmetric) the filter length must be 4n-1 (n = some integer) > > and the middle coefficient will be equal to the sum of the other > > coefficients. Of course one needs to define a half-band filter as being > > symmetrical in the frequency domain for this to apply. > > I'm missing something. For n = 1 we get N= 4*1-1 = 3 nonzero taps, > which is the lowest odd order of a nontrivial symmetric FIR filter. > So far so good. > > Next, set n = 2 and get N = 4*2-1 = 7. > > Why is N = 5 not an admissible number of nonzero taps? It's odd > and it's possible to construct an (anti)symmetric impulse response? >
Yes, the impulse response is symmetric, but what you want is a frequency response where the pass band and stop band are mirror images (for purposes of this discussion magnitude and frequency must be viewed as linear not logarithmic). So if we think of constructing the filter as adding pairs of symmetric coefficients on the ends, then each pair adds another cosine function to the frequency response. But only the odd cosine functions can have the proper symmetry to meet the half-band definition. So all pairs an even distance from the center tap must be zero. -jim
"jim" <"N0sp"@m.sjedging@mwt.net> wrote in message 
news:419ca8bc$1_3@127.0.0.1...
> > > Juha wrote: > >> It is not exactly true that the middle coefficient will be equal to the >> sum of the other coefficients. The sum of the coefficients is equal to >> magnitude response at the zero frequency and for the half-band filters >> the magnitude response at zero frequency is either 1-delta or 1+delta >> where delta is the ripple in the pass- and stopband. >> >> Of course, the filter can be scaled some other way but in this case the >> correspondin lowpass-highpass filter pair can be implemented as a > > Yes, point is valid. It comes down to how you choose to define things. > We would both agree that if the DC gain of the filter is 1.0 then the > absolute sum of the side coefficients is 0.5 and the middle coefficient > is also 0.5. Now if you simply scale the filter one could argue that is > no different than using the same filter and scaling the output. Or... > you could argue as you do, that scaling will change the symmetry of the > filter. If we would agree that regardless of the scaling the perfect > balance between the pass band and stop band must be maintained then the > center tap must always be 0.5. > > -jim > > > > >> parallel connection of G(z^2) and 1/2z^{-M}, where M is the half the >> filter order and the zero-phase response H(omega) satisfies >> H(omega)+H(pi-omega)=1. >> >> % Matlab code >> M = 21; % must be odd >> passbandEdge = 0.4; h = []; >> h((M+1):M:(2*M+1)) = [0.5 0]; >> [g, ripple] = remez(M, [0 2*passbandEdge 1 1], ... >> [0.5 0.5 0 0], {128}) >> >> h(1:2:end) = g(1:end); >> [H, w] = freqz(h, 1, 2^10, 2); >> iPassband = find(w <= passbandEdge); >> plot(w(iPassband), abs(H(iPassband))) >> >> disp(['ripple = ' num2str(ripple) ' = ' num2str(abs(1-abs(H(1)))) ... >> ' = ' num2str(abs(1-sum(h)))]) >> >> -- >> Juha
Agreed. Although you have to be somewhat careful what you call a halfband filter. For example, the gain at frequency=0 can be exactly 1.0 if you want that to be the case - while meeting antisymmetry and being minimax (subject to the constraint). However, with this constraint you most likely use up one of the degrees of freedom - so the ripple will be higher. But, remez in Matlab won't get you there I believe. I like to think of a half-band filter as one that has a sum of odd cosines plus a constant. The sum of the cosines is zero at fs/4 and 3fs/4. The constant must be such that the value at f=0, is related to the value at fs/2 as follows: F(0) less the constant is the sum of the cosine coefficients. F(fs/2) less the constant is minus the sum of the cosine coefficients. Same scaling property..... If the value at f=0 is 1.0, then the value at fs/2 is 0.0. If the value at f=0 is 1.0+delta, then the value at fs/2 is -delta where delta can be a negative number as well as positive. So, the constant has value 0.5 and F(0)= 0.5 + sum of coefs and F(fs/2)=0.5 - sum of coeffs Fred

Fred Marshall wrote:

> "jim" <"N0sp"@m.sjedging@mwt.net> wrote in message
> > Juha wrote: > > > >> It is not exactly true that the middle coefficient will be equal to the > >> sum of the other coefficients.
> > If we would agree that regardless of the scaling the perfect > > balance between the pass band and stop band must be maintained then the > > center tap must always be 0.5.
> > Agreed. Although you have to be somewhat careful what you call a halfband > filter. For example, the gain at frequency=0 can be exactly 1.0 if you want > that to be the case - while meeting antisymmetry and being minimax (subject > to the constraint). However, with this constraint you most likely use up > one of the degrees of freedom - so the ripple will be higher. But, remez in > Matlab won't get you there I believe. > > I like to think of a half-band filter as one that has a sum of odd cosines > plus a constant. The sum of the cosines is zero at fs/4 and 3fs/4. The > constant must be such that the value at f=0, is related to the value at fs/2 > as follows: > > F(0) less the constant is the sum of the cosine coefficients. > F(fs/2) less the constant is minus the sum of the cosine coefficients. > Same scaling property..... > If the value at f=0 is 1.0, then the value at fs/2 is 0.0. > If the value at f=0 is 1.0+delta, then the value at fs/2 is -delta where > delta can be a negative number as well as positive. > So, the constant has value 0.5 and F(0)= 0.5 + sum of coefs and > F(fs/2)=0.5 - sum of coeffs
Yes, your saying the same as Juha. But consider these 2 filters. [1 2 1] [1 2 1]/4 By your definition the second is a half-band filter and the first is not. Now someone might point out that the only difference in the output of the 2 filters is a gain of 4. Personally, I tend to find it more often useful to view the DC gain as separated from the frequency response. But, your definition is valid and its not to difficult to construct scenario's where it would produce a more useful filter. -jim ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---