DSPRelated.com
Forums

hilbert transform application

Started by sundar July 21, 2004
Stephan M. Bernsee <spam@dspdimension.com> wrote...
> You can calculate the Hilbert transformed signal using the FFT though, > by zeroing out the negative frequencies and multiplying by 2 before > doing the inverse transform.
I'm familiar with this approach (e.g. it is apparently implemented in the hilbert() function of Matlab's Signal Processing Toolbox, http://www-ccs.ucsd.edu/matlab/toolbox/signal/hilbert.html). You can equivalently gain an additional factor of two in speed by exploiting the (usual) case where the input data are real (essentially by swapping/sign-flipping the real and imaginary parts instead of zeroing). I have some code for this with FFTW which I thought about posting, but I was told that this is not really the "right" way to compute the Hilbert transform -- if the input data are non-periodic, to avoid artifacts you should really implement an FIR filter with +/- response for positive and negative frequencies, as described e.g. in Oppenheim & Schafer. I'm not a signal processing expert, so I'm curious if anyone has a reference to indicate whether the FFT-based method ala Matlab is actually useful for serious applications, and how it compares to the FIR approach. Cordially, Steven G. Johnson
This is a good observation. IMHO, both of them are correct but just
realistic or not.

The FIR approach is more conventional to LTI system concept: a filter
sitting there waiting for input signals and generating output. While
the FFT approach uses the analytic sequence properties and needs to
collect certain amount of data then apply FFT with parameters like
length, etc. It is easier to implement on paper but hard in practice.

As for the comparison of these two, as far as I know the 2-D HT are
normally using FFT approach. For 1-D, both.

stevenj@alum.mit.edu (Steven G. Johnson) wrote in message news:<27cfb406.0407280640.65cff90b@posting.google.com>...
> Stephan M. Bernsee <spam@dspdimension.com> wrote... > > You can calculate the Hilbert transformed signal using the FFT though, > > by zeroing out the negative frequencies and multiplying by 2 before > > doing the inverse transform. > > I'm familiar with this approach (e.g. it is apparently implemented in > the hilbert() function of Matlab's Signal Processing Toolbox, > http://www-ccs.ucsd.edu/matlab/toolbox/signal/hilbert.html). You can > equivalently gain an additional factor of two in speed by exploiting > the (usual) case where the input data are real (essentially by > swapping/sign-flipping the real and imaginary parts instead of > zeroing). > > I have some code for this with FFTW which I thought about posting, but > I was told that this is not really the "right" way to compute the > Hilbert transform -- if the input data are non-periodic, to avoid > artifacts you should really implement an FIR filter with +/- response > for positive and negative frequencies, as described e.g. in Oppenheim > & Schafer. > > I'm not a signal processing expert, so I'm curious if anyone has a > reference to indicate whether the FFT-based method ala Matlab is > actually useful for serious applications, and how it compares to the > FIR approach. > > Cordially, > Steven G. Johnson
[ I had asked about computing Hilbert transforms via FIR filters ala
Oppenheim & Schafer vs. the FFT approach ala Matlab, and whether the
FFT approach's periodic boundaries were a problem. ]

steven_hyh@yahoo.com (Steve) wrote...
> This is a good observation. IMHO, both of them are correct but just > realistic or not.
This answer doesn't make sense to me. The two approaches don't compute exactly the same thing -- the FFT and FIR make *different* approximations in estimating the Hilbert transform of an infinite signal from a finite-length sample. Depending upon the application, they are certainly not always equally "correct", with the difference being only one of implementation. Regards, Steven G. Johnson
Hi guys, 

I want to thank you all for all your valuable suggestions. I have a
question, I read in this book that.....if i do

x(t)-----> fft-----> X(f)------->X(f)*exp(i*pi/2)---------->
ifft--------H[x(t)].

In other words, if i do a fft on x(t) and then phase shift it and then
do a ifft i am supposed to get the hilbert transform of x(t). Fine,
well and good, but in matlab after i do this above method and then
directly use the matlab hilbert function....hilbert(x(t))....i get
different values.

Have i understood something wrong....or whats happening.Any clue.

Secondly iam looking for a IEEE paper which talks about how hilbert
transform works in matlab. I had no luck finding it, does anyone have
any idea what iam talking about.

Please help. Any advise is heartly appreciated.

Regards

Sundar
> [ I had asked about computing Hilbert transforms via FIR filters ala > Oppenheim & Schafer vs. the FFT approach ala Matlab, and whether the > FFT approach's periodic boundaries were a problem. ] > > steven_hyh@yahoo.com (Steve) wrote... > > This is a good observation. IMHO, both of them are correct but just > > realistic or not. > > This answer doesn't make sense to me. The two approaches don't > compute exactly the same thing -- the FFT and FIR make *different* > approximations in estimating the Hilbert transform of an infinite > signal from a finite-length sample. Depending upon the application, > they are certainly not always equally "correct", with the difference > being only one of implementation.
Ok, see if this example makes sense to you: % Create a sinusoid real signal t = 0 : 0.1 : 9.9; Xr = cos(2*pi*t); % the hilbert transform, in theory, we know it is a sinusoidal too. % so, the first method, using matlab's hilbert implementation. Matlab's method % uses FFT method as you desribed. X = hilbert(Xr); % Note that X is Xr + jXi, not the real hilbert sequence % Now this is the ture hilbert transform of Xr X_hilb = imag(X); % Obviously, X_hilb is a sinusoidal function, which meets theory % Now turn to FIR approach B = remez(30,[0.1 0.9],[1 1],'Hilbert'); Y = filter(B,1,Xr); % You need to take care of delay here. I skip this part. % But you can plot to see what is going on plot(Y) hold on plot(X_hilb) % except some delay, they are the same They are both approximation to ideal hilbert transform. But they should generate the same result. If you want to prove the uniqueness of hilbert transform, that is another story. As for the "correctness" you keep mentioning, if you can provide some examples(codes or equations) to show what you mean, that is bettern than words.
steven_hyh@yahoo.com (Steve) wrote...
> They are both approximation to ideal hilbert transform. But they > should generate the same result.
Sigh... Yes, they are both approximations to the ideal transform, but they are not the *same* approximation, and they do *not* generate *exactly* the same result. Even in the example case you posted, if you zoom in on the plots you can see clear differences between the results of the two methods (e.g. the amplitudes differ by about 0.3%). My question was, how do the errors compare, and are there circumstances under which one approximation is known to be significantly better than the other? Cordially, Steven G. Johnson