Frequency domain filtering in Matlab

Click For Summary

Discussion Overview

The discussion revolves around implementing various filters in Matlab for Fourier domain filtering, specifically focusing on cosine, Shepp-Logan, and Hann/Hamming window filters. Participants explore the effects of a parameter ##d## on the filter responses and seek clarification on its justification and calculation.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes the implementation of filters in Matlab and notes discrepancies in the expected versus actual filter responses, particularly influenced by the parameter ##d##.
  • Another participant questions the results obtained when setting ##d=1## and suggests normalization might be a factor.
  • A subsequent reply raises the possibility of a units issue related to degrees/radians/frequency in the calculations.
  • One participant shares an alternative formulation for the filters that includes normalization, questioning the need for different frequency scaling factors in the formulas.
  • Another participant proposes that the parameter ##d## relates to cut-off frequency and should be less than the Nyquist frequency to avoid aliasing.
  • A later reply points out a potential issue with the argument used in the trigonometric functions, suggesting that the argument should be in angular frequency rather than frequency divided by ##2\pi##.

Areas of Agreement / Disagreement

Participants express differing views on the role and calculation of the parameter ##d##, as well as the appropriate scaling of frequency in the filter equations. The discussion remains unresolved with multiple competing perspectives on these issues.

Contextual Notes

Participants mention normalization and potential units issues, but the specific assumptions and definitions related to frequency and the parameter ##d## are not fully clarified.

roam
Messages
1,265
Reaction score
12
I am trying to implement several filters in Matlab for Fourier domain filtering. They are the cosine, Shepp-Logan, and Hann/Hamming window filters. These filters are defined as multiplying the ramp filter by the cosine function, sinc function, and Hann/Hamming windows respectively.

This is how the responses of these filters should look like:

tiki-download_file.php?fileId=433&display.jpg

However, this is what I am getting:

filters.jpg


I have defined the filters exactly as they are defined in this Matlab function, with a parameter ##d## that stretches the filters:

Code:
w=linspace(0, 1, 181).'; % Frequency axis

d=0.33;

Hr = abs(w); % Ramp filter

H=Hr.* cos(w/(d)); % Cosine filter
H(H<0) = 0; 

H=Hr.* (sin(w/d)./(w/d)); % Shepp-Logan filter
H(H<0) = 0; 

H=Hr.* (1+cos(w./d)) / 2; % Hann filter
H(H<0) = 0; 

H=Hr.* (.54 + .46 * cos(w/d)); % Hamming filter
H(H<0) = 0;

For instance, if I change it to ##d=0.3##, the Hann/Hamming filters start to look correct. And at ##d=0.65##, the cosine filter looks more correct:

d3filter.jpg


So, what is the justification for using the parameter ##d##? And is there an algorithm for calculating it accurately for each filter?

Any explanation would be greatly appreciated.
 
Physics news on Phys.org
What do you get for d=1? I am guessing it might have to do with normalization?
 
  • Like
Likes   Reactions: roam
PhysicoRaj said:
What do you get for d=1? I am guessing it might have to do with normalization?
The second plot above is d=1. I suspect there is a degree/radian/frequency units issue.
 
  • Like
Likes   Reactions: PhysicoRaj and roam
I tried to plot the graphs without the ##d## but instead using some kind of normalization. This is the combination that produced the correct results:

$$H=|\omega| \cos \left( \frac{\omega}{2 \pi} \right)$$

$$H=|\omega| \left( \frac{\sin \left( \frac{\omega}{2 \pi} \right)}{\left( \frac{\omega}{2 \pi} \right)} \right)$$

$$H = |\omega| \frac{1+\cos(\omega \pi)}{2}$$

$$H = |\omega| (0.54 + 0.46 \cos (\omega \pi))$$

Is there any reason why we need to divide the frequency in the first two by ##2 \pi##, but multiply it by ##\pi## in the Hann and Hamming window?

It was a trial and error approach, so I am not sure. :confused:
 
d has to do with cut-off frequency I guess. It must be lower than Nyqvist frequency to prevent aliasing and d=0.33 means that it is only 33% of Nyqvist frequency.
 
@roam You seem to be using Cos(ω/2π) on your calculations. The argument in a trig function should not be frequency (ω/2π). It should be in angular frequency (ω). This could be some of your problem.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
14K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
6K