2
$\begingroup$

I believe I have a fundamental misunderstanding of windowing. I thought that windowing is applied to a signal with pointwise multiplication, then some sort of filtering is then done to it (say using convolution in the time domain). However, looking back at my previous assignment, I seem to have applied the window to the filter itself(might be remembering incorrectly), which effectively means I convolved the signal with the window? Also, for images, it seems that I need to apply the window to a 2d kernel and not the image itself. This kernel then gets convolved with the image which means that I am once again convolving the image with the window, instead of pointwise multiplying. I understand that windowing is done to prevent spectral leakage/aliasing, but I dont quite get why it is being applied to the filter than the image itself.

If anyone could correct my misunderstanding I would be very grateful.

$\endgroup$
2
$\begingroup$

Your description of windowing a 2D image filter kernel, fits into a discrete-time FIR filter design method. Hence I will assume you are mixing windowing as a filter design method vs windowing applied to signals for Short-Time Fourier analysis or windowing applied for block-based processing of long signals. So please make it clear which action you are performing and the context of your intentions.

Then let me briefly describe windowing as a filter design tool.

An ideal discrete-time frequency selective LTI filter will have an infinite length and noncausal impulse response $h_i[n]$. So it shall be truncated and delayed for any practical FIR convolution applications.

Given an ideal filter impulse response $h_i[n]$, you obtain the coefficients of the practical impulse response $h[n]$ of length N samples via

$$h[n] = w[n] h_i[n]$$

Which is the point wise multiplication of the filter $h_i[n]$ with a window sequence $w[n]$ of length N. The main purposes of the window is to first truncate the infinite length ideal impulse response, and then to try to cure the side effects on the resulting filter spectrum caused by the crude truncation.

There are many different types of windows such as box-car,triangular, Hamming, Hanning, Blackman, Kaiser. The box-car is the crude rectangular window without any tapering. Other windows perform varying degrees of tapering at the ends of the impulse response so as to achieve a tradeoff between filter transition bandwith and passpand / stopband peak ripples.

Note that the windows's frequency response $W(e^{j\omega})$ is convolved with the ideal filter frequency response $H_i(e^{j\omega})$ which yields the frequency response of the practical filter;i.e,

$$H(e^{j\omega}) = \frac{1}{2\pi} H_i(e^{j\omega}) \star W(e^{j\omega}) $$.

$\endgroup$
  • 1
    $\begingroup$ robert, fat32: both of your explanations were great. but, I have a dumb question. your answers I think imply that windowing is always done in the time domain. is that correct ? I thought I heard of windowing in the frequency domain which confuses me, even though I understand it in the time domain. thanks. $\endgroup$ – mark leeds Sep 10 '18 at 4:11
  • 1
    $\begingroup$ @markleeds Hi mark! Just as (linear) independence vs (statistical) independence, the term windowing can also have different meanings in different contexts... As a filter design method, it has the meaning as in my answer. As a Short-Time FT tool it has a meaning like in RBJ's answer. However be careful to distinguish between, action (windowing as multiplication) in time domain and its effect (as convolution) in frequency domain due to $$x[n]w[n] \leftrightarrow X(w) \star W(w). $$ Note that multiplication in frequency domain is typically called masking or weighting instead. $\endgroup$ – Fat32 Sep 10 '18 at 11:06
  • 1
    $\begingroup$ @markleeds Furthermore note that multiplication in frequency domain also equals convolution in time domain. So when you multiply (action) the DTFT $X(w)$ with window signal $W(w)$ in frequency domain, then effectively you are convolving (filtering) their time domain sequences as $$x[n] \star w[n] \leftrightarrow X(w)W(w)$$ indicates. So methematical expression is clear, but the intention and context must also be made clear to achieve the same meaning in both parties... $\endgroup$ – Fat32 Sep 10 '18 at 11:12
  • 1
    $\begingroup$ @robertbristow-johnson Yes I saw the possible confusion later, I knew you would see that :-) but \omega takes too long and 7x more characters especially when repeated in a comment... Hope it doesn't cause confusion for people though it would cause a definite confusion for a compiler ! $\endgroup$ – Fat32 Sep 10 '18 at 20:53
  • 1
    $\begingroup$ Thanks to everyone who replied to my question. My DSP knowledge is pretty thin so I will print it all out and try to absorb it all over this week. All of the comments-explanations are much appreciated. This dsp.stackexchange community is an amazing group to learn from. All the best. $\endgroup$ – mark leeds Sep 11 '18 at 4:49
1
$\begingroup$

assuming the window is of finite length, the application of a sliding window (a window re-applied every new sample to the most current $N$ samples) is the same as an FIR filter. the window sample values, $w[n]$, are the same as the tap values or the Finite Impulse Response of an FIR filter.

now maybe you might be referring to the reciprocal fact that windowing in one domain (time or frequency) corresponds to convolution in the other reciprocal domain. is that it?

$\endgroup$
  • 1
    $\begingroup$ Sorry, I did a bit more research and I think I know what I need to understand before I clear up this misunderstanding. First of all, I understand that there is this idea of spectral leakage when applying fft to a signal received from the time domain. This is because when the signal is passed through the fft, an inherently aperiodic signal is stitched together which forms discontinuities at the edges of the signal, which result in high frequencies appearing in the frequency spectrum. $\endgroup$ – Xymistic Sep 10 '18 at 1:08
  • $\begingroup$ So my first question is why is windowing necessary when designing FIR filters? I read that windowing 1. Truncates the filter to a finite resolution (an ideal box filter in the frequency domain is transformed into a sinc in the time domain with infinite resolution. Applying a window now gives it finite resolution.) 2. Reduces the gibbs phenomena. Wait, after typing that out it seems like windowing is applied in the time domain to the filter and not to the signal itself? Is that right? $\endgroup$ – Xymistic Sep 10 '18 at 1:14
  • 1
    $\begingroup$ your first comment is exactly correct, the FFT is just an efficient method of the DFT, and the DFT always periodically extends the $N$ samples of data passed to it. the DFT thinks those $N$ samples are one cycle of a periodic waveform that repeats every $N$ samples. this is that "stiching together" you refer to. but there is an equivalent way of looking at the DFT in that your $N$ samples are zero-extended, we apply the DTFT, which evaluates $H(z)$ on the unit circle ($z=e^{j\omega}$) and the DFT samples that unit circle at $N$ equally-spaced points. $\endgroup$ – robert bristow-johnson Sep 10 '18 at 1:46
  • 1
    $\begingroup$ windowing is not always necessary to design FIR filters. Parks-McClellan (firpm()) and Weighted Least-Squares (firls()) are two methods of designing FIR filters that are not the Windowing Method. the windowing method is 1. Draw out the desired frequency response. 2. applying Hermitian symmetry, inverse FFT to get the Impulse Response. 3. shorten the Impulse response to the finite length of the FIR. windowing is what happens when you shorten the impulse response to the length $L$ that you can pay for. $\endgroup$ – robert bristow-johnson Sep 10 '18 at 1:52
  • $\begingroup$ i think your questions should be migrated to your question and my answers should be migrated to the answer. $\endgroup$ – robert bristow-johnson Sep 10 '18 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.