DSPRelated.com
Forums

Hilbert transform & analytic signals

Started by Rick Lyons July 14, 2003
Hi Guys,

  I've been modeling (with MATLAB) the Hilbert transform 
for use in generating the analytic signal (a complex 
signal) corresponding to a real signal x(n).  That is, 
I'm computing a complex signal whose real part is x(n) 
and whose imaginary part is the Hilbert transform of x(n).
I can use MATLAB's remez() command specifying 'Hilbert' 
to get an FIR Hilbert filter that will generate the imaginary 
part of my desired complex signal.
OK, no big deal.

Another idea for generating an analytic signal, that's 
bounced around this newsgroup for quite a while, is 
designing a lowpass filter and translating its center 
frequency to Fs/4 by multiplying the lowpass coefficients 
by exp(j*2*pi*Fs/4*Time), resulting in a complex filter 
centered at Fs/4.  That complex filter would then be 
implemented as a dual-path filter where the I-path is a real- 
coefficient filter having coefficients equal to the real 
part of exp(j*2*pi*Fs/4*Time), and the Q-path is a real- 
coefficient filter having coefficients equal to the imaginary 
part of exp(j*2*pi*Fs/4*Time).
This all fine.

Here's what I've seen: The passband magnitude response ripple 
using a remez-designed FIR Hilbert filter (floating point 
numbers) having around 30 taps is roughly 0.1 dB peak-peak. 
To get that same peak-peak passband ripple using the 
complex filter scheme seems to require 3-4 times as many taps!!

If my modeling is correct, the complex-filter scheme for 
generating an analytic signal requires *many* more multiplies 
than the traditional FIR Hilbert method.

Have any of you guys modeled these two methods and seen the 
same effects that I've seen?
Have I screwed something up here?

Thanks much,
[-Rick-]


Rick,
Have you tried other methods to do the filter development, other than
the Remez, I have noticed with certain characteristics for inputs the
Remez has a difficulty getting get results, however, if I go straight
to the actual design equations for the Remez or Park's Mcclellon
(however it is spelled) I get a crisp a nice crisp answer.  You might
play around with this fact, if I get time I may see if I can generate
some code that I will post later that may show this point, but work is
pretty busy right now, so it may not be anytime soon.

good luck,

Craig

ricklyon@REMOVE.onemain.com (Rick Lyons) wrote in message news:<3f135667.60818218@news.earthlink.net>...
> Hi Guys, > > I've been modeling (with MATLAB) the Hilbert transform > for use in generating the analytic signal (a complex > signal) corresponding to a real signal x(n). That is, > I'm computing a complex signal whose real part is x(n) > and whose imaginary part is the Hilbert transform of x(n). > I can use MATLAB's remez() command specifying 'Hilbert' > to get an FIR Hilbert filter that will generate the imaginary > part of my desired complex signal. > OK, no big deal. > > Another idea for generating an analytic signal, that's > bounced around this newsgroup for quite a while, is > designing a lowpass filter and translating its center > frequency to Fs/4 by multiplying the lowpass coefficients > by exp(j*2*pi*Fs/4*Time), resulting in a complex filter > centered at Fs/4. That complex filter would then be > implemented as a dual-path filter where the I-path is a real- > coefficient filter having coefficients equal to the real > part of exp(j*2*pi*Fs/4*Time), and the Q-path is a real- > coefficient filter having coefficients equal to the imaginary > part of exp(j*2*pi*Fs/4*Time). > This all fine. > > Here's what I've seen: The passband magnitude response ripple > using a remez-designed FIR Hilbert filter (floating point > numbers) having around 30 taps is roughly 0.1 dB peak-peak. > To get that same peak-peak passband ripple using the > complex filter scheme seems to require 3-4 times as many taps!! > > If my modeling is correct, the complex-filter scheme for > generating an analytic signal requires *many* more multiplies > than the traditional FIR Hilbert method. > > Have any of you guys modeled these two methods and seen the > same effects that I've seen? > Have I screwed something up here? > > Thanks much, > [-Rick-]
"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message
news:3f135667.60818218@news.earthlink.net...
> Here's what I've seen: The passband magnitude response ripple > using a remez-designed FIR Hilbert filter (floating point > numbers) having around 30 taps is roughly 0.1 dB peak-peak. > To get that same peak-peak passband ripple using the > complex filter scheme seems to require 3-4 times as many taps!!
To compare the two approaches, make the complex filter corresponding to the Hilbert transform method -- multiply the hilbert filter by j, add 1 (real) to the zeroth coefficient, and phasor-modulate the passband down to 0Hz. You can then compare the features of this "hilbert halfband" with the halfband prototype you designed directly. I think you'll notice the passband isn't the same shape as the stopband. You'll also notice that the filter is complex and not quite linear-phase. Each of these flaws increases the number of degrees of freedom available to the remez design process, which is why imposing the complementary restrictions leads to a requirement of 4 times as many taps. If you really don't care about those things, though, you can still use your directly designed halfband prototype -- just dispense with the real-part filtering like you do with the Hilbert method, and notice that half the imaginary part coefficients are zero, leading to a 4x speedup in the implementation, on par with the Hilbert method.
On Tue, 15 Jul 2003 01:18:27 GMT, ricklyon@REMOVE.onemain.com (Rick
Lyons) wrote:

Hi Guys,

Shoot!  I didn't explain myself properly.

Here's what I wrote:
> >Here's what I've seen: The passband magnitude response ripple >using a remez-designed FIR Hilbert filter (floating point >numbers) having around 30 taps is roughly 0.1 dB peak-peak. >To get that same peak-peak passband ripple using the >complex filter scheme seems to require 3-4 times as many taps!!
That last sentence should have said: To get that same peak-peak passband ripple *difference* between the two real filters using the complex filter scheme seems to require 3-4 times as many taps in each filter!! If my modeling is correct, the complex-filter scheme for generating an analytic signal requires *many* more multiplies than the traditional single-FIR-filter Hilbert method. Thanks, [-Rick-]
> >
On 15 Jul 2003 05:37:57 -0700, crrea2@umkc.edu (Craig) wrote:

>Rick, >Have you tried other methods to do the filter development, other than >the Remez, I have noticed with certain characteristics for inputs the >Remez has a difficulty getting get results, however, if I go straight >to the actual design equations for the Remez or Park's Mcclellon >(however it is spelled) I get a crisp a nice crisp answer. You might >play around with this fact, if I get time I may see if I can generate >some code that I will post later that may show this point, but work is >pretty busy right now, so it may not be anytime soon. > >good luck, > >Craig
Thanks Craig. [-Rick-]
In article 82396605.0307150437.7703c267@posting.google.com, Craig at
crrea2@umkc.edu wrote on 07/15/2003 08:37:

> Rick, > Have you tried other methods to do the filter development, other than > the Remez,
yeah, check out the firls() function in MATLAB, Rick. r b-j
Rick,

Can you post your MATLAB filter design script?

When you say 3-4 times more taps are you counting the half of the real
and half of the imaginary taps that should be 0 after the mix?

Dirk

Dirk Bell

ricklyon@REMOVE.onemain.com (Rick Lyons) wrote in message news:<3f13fc8e.103352734@news.earthlink.net>...
> On Tue, 15 Jul 2003 01:18:27 GMT, ricklyon@REMOVE.onemain.com (Rick > Lyons) wrote: > > Hi Guys, > > Shoot! I didn't explain myself properly. > > Here's what I wrote: > > > >Here's what I've seen: The passband magnitude response ripple > >using a remez-designed FIR Hilbert filter (floating point > >numbers) having around 30 taps is roughly 0.1 dB peak-peak. > >To get that same peak-peak passband ripple using the > >complex filter scheme seems to require 3-4 times as many taps!! > > > That last sentence should have said: > > To get that same peak-peak passband ripple *difference* > between the two real filters using the > complex filter scheme seems to require 3-4 times as many taps > in each filter!! > > If my modeling is correct, the complex-filter scheme for > generating an analytic signal requires *many* more multiplies > than the traditional single-FIR-filter Hilbert method. > > Thanks, > [-Rick-] > > > >
Rick:

[snip]
"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message
news:3f135667.60818218@news.earthlink.net...
> Hi Guys,
: :
> Another idea for generating an analytic signal, that's > bounced around this newsgroup for quite a while, is > designing a lowpass filter and translating its center
: :
> If my modeling is correct, the complex-filter scheme for > generating an analytic signal requires *many* more multiplies > than the traditional FIR Hilbert method. > > Have any of you guys modeled these two methods and seen the > same effects that I've seen? Have I screwed something up here?
[snip] I use this technique often, but I use IIR filters rather than FIR! It works really well with an IIR filter translated/rotated to place its' transition band at the origin and the IIR filter consumes a lot fewer multiply-adds and memory than either of the FIR [Hilbert or Filter] techniques. A relatively simple low order IIR complex filter does a very efficient job of separating positive frequencies from negative frequencies and can be readily used to generate analytic signals to any prescribed degree of "purity" [measured in dB of negative frequency suppression] desired. -- Peter Consultant Indialantic By-the-Sea, FL.
On Wed, 16 Jul 2003 00:47:40 -0400, "Peter Brackett"
<ab4bc@ix.netcom.com> wrote:

>Rick: > >[snip] >"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message >news:3f135667.60818218@news.earthlink.net... >> Hi Guys, >: >: >> Another idea for generating an analytic signal, that's >> bounced around this newsgroup for quite a while, is >> designing a lowpass filter and translating its center >: >: >> If my modeling is correct, the complex-filter scheme for >> generating an analytic signal requires *many* more multiplies >> than the traditional FIR Hilbert method. >> >> Have any of you guys modeled these two methods and seen the >> same effects that I've seen? Have I screwed something up here? >[snip] > >I use this technique often, but I use IIR filters rather than FIR! > >It works really well with an IIR filter translated/rotated to place its' >transition band at the origin and the IIR filter consumes a lot fewer >multiply-adds and memory than either of the FIR [Hilbert >or Filter] techniques. > >A relatively simple low order IIR complex filter does a very efficient >job of separating positive frequencies from negative frequencies >and can be readily used to generate analytic signals to any prescribed >degree of "purity" [measured in dB of negative frequency suppression] >desired. > >-- >Peter >Consultant >Indialantic By-the-Sea, FL.
Hi Peter, Interesting. I've never used an IIR filter to implement a Hilbert transform. However, I've read that IIR Hilbert transformers don't yield the desired exact 90-degree phase shift. By the way, how do you go about translating a lowpass IIR filter's passband center frequency up to, say, Fs/4? Thanks, [-Rick-]
On 15 Jul 2003 11:53:58 -0700, dirkman@erols.com (Dirk Bell) wrote:

>Rick, > >Can you post your MATLAB filter design script? > >When you say 3-4 times more taps are you counting the half of the real >and half of the imaginary taps that should be 0 after the mix? > >Dirk >
Hi Dirk, yep the numbers I quoted include the zero-valued coefficients. What I've found is that a Hilbert FIR filter of 27 coefficients will have a magnitude peak-peak ripple of roughly 0.1 dB. The two real filters (making up the single complex filter used to generate an analytic signal) had to have over 100 coefficients each to keep the difference in their magnitude responses within 0.1 dB. If my modeling is correct, that 'complex filter' method for generating an analytic signal, from a real signal, requires about eight times as many multiplies as an equivalent single Hilbert FIR filter!! Here's my MATLAB code: clear %%% Design a Hilbert transformer (FIR) Ntaps = 27; % Number of taps in Hilbert FIR B_Quad = remez(Ntaps-1,[.1 .9],[1,1],'hilbfilt'); % Zero -out the coeffs that should be zero B_Quad(abs(B_Quad)<0.00001) = 0; MagB = abs(fft(B_Quad,512)); MagB = 20*log10(MagB/max(MagB)); MagB(MagB<-1) = -1; % Threshold figure(1), plot(MagB,'-b'), grid on, zoom on xlabel('Freq'), ylabel('dB') title('Mag of Hilb-FIR filter') % Now design the complex FIR filter % **** Design the lowpass FIR filter first ****** F_pass = 0.4; % Filter's cutoff freq F_stop = 0.45; % Beginning of stopband F = [0,F_pass,F_stop ,1 ]; % Freq vector for remez M = [1,1,0,0 ]; % Mag vector for remez N_taps = 107; % Number of FIR filter taps N = N_taps-1; B_LP = remez(N,F,M); % Calc the lowpass filter's coeffs %B_LP = B_LP.*hanning(N_taps)'; % Window if you want. %B_LP = 2*B_LP; % Gain compensation, if you want % **** Translate LP filter to a BP filter (complex) *** Mix_Seq = exp(j*(pi/2)*(0:N_taps-1)); % complex expon. at Fs/4. B_BP = B_LP.*Mix_Seq(1:N_taps); % Freq translation. B_Inphase = real(B_BP); % BP filter coeffs real parts B_Quad = imag(B_BP); % BP filter coeffs imag parts MagReal = abs(fft(B_Inphase,512)); MagImag = abs(fft(B_Quad,512)); MagReal = 20*log10(MagReal/max(MagReal)); % Log ref at 0 dB. MagImag = 20*log10(MagImag/max(MagImag)); MagReal(MagReal<-1) = -1; % Threshold MagImag(MagImag<-1) = -1; figure(2), plot(MagReal,'-b'),hold on, plot(MagImag,'-r') plot(MagReal-MagImag,'-k'), hold off, grid on, zoom on title('Magnitudes: I filter-blue, Q filter-red, difference-black,') xlabel('Freq'), ylabel('dB') Thanks Dirk, [-Rick-]