3
$\begingroup$

I'm very confused about downsampling in image processing and the use of sinc function to do it. I read this post [1]: 2D Fourier downsampling some time ago that talked about my own doubt, that is to downsample an image in fourier domain (for personal knowledge). The answer of this post was to crop the center of the Fourier spectrum to the desired output size of the new image (with different dimensions than the original ones). Other posts talks about downsampling the image via sinc. I therefore have various questions:

  1. Cropping the Fourier spectrum with a square (assuming the dimensions of the cropped image are squared), doesn't that mean applying a box filter ( that is the fourier transform of a sinc) ? If yes, does applying a sinc or cutting the center of spectrum of fourier correspond to the same thing? If not, how does cutting the Fourier spectrum downsample the image once the inverse fft is done?
  2. Why sinc is used to downsampling image? How does it downsample?
$\endgroup$

2 Answers 2

2
$\begingroup$

Downsampling operation, with an integer factor M, involves two steps: first a lowpass filtering is applied to bandlimit the input so as to avoid any possible aliasing, then a compressor (decimator) throws out all but every M-th sample, producing the output.

The ideal lowpass filter used in this process is also known as a sinc filter, since its impulse response is indeed a sinc function; hence the name.

An LTI filtering operation can be performed either in time-domain using a convolution, or equivalently in frequency-domain using multiplication of associated discrete-Fourier transforms (DFT) of the input and the filter.

However, eventhough the discrete-time Fourier transform (DTFT) of an ideal sinc filter is an exact rectangular pulse in the frequency domain, the discrete-Fourier transform (DFT) of an ideal sinc filter (which extends to +- infinity) does not exist: because only finite length signals do have DFT reprsentations.

In practice, therefore, a finite length truncated sinc filter must be used, and the resulting errors must be tolerated. A raw truncation, however, exhibits heavy untolerable Gibbs phenomenon (ripples on pulse edges) on the resulting DTFT and DFT of the sinc filter. To avoid these excessive ripples, a tapering window is applied to the truncated impulse response. The result is that, DFT/DTFT of the windowed-truncated sinc function avoids excessive ripples, whereas the transition bandwidth of the lowpass filter is widened.

Eventually, the DTFT/DFT of the windowed truncated sinc filter approaches that of the rectangular pulse in the frequency-domain. This implies that a rectangular mask in the frequency-domain can perform close to (but not exact to) an windowed truncated sinc filter in the time-domain. This is the reason, why sometimes lowpass filtering can be applied in the frequency-domain using an exact rectangular mask applied to the DFT of the input signal. Applying a mask, instead of a multipication of the true DFT of the windowed- truncated sinc filter, is the cheapest way to filter a signal at the cost of some aliasing (or truncation) errors with respect to an (unimplementable) ideal sinc filter or a practical windowed truncated sinc filter; yet it may perform satisfactorily depending on the application.

This rectanguar mask can be aplied at the center of the frequency spectrum if the spectrum is represented using a symmetric $[-\pi,\pi]$ interval, instead of the typical $[0,2\pi]$ implied by DTFT/DFT definitions. Nevertheless, they are equivalent, and can be converted to each other using an FFT shift operator available on most platforms.

Note that you can totally ignore the lowpass filtering stage if the original sigal is already at least M times oversampled (in case of downsampling by integer M), and just compress the input samples to produce the output samples.

$\endgroup$
8
  • $\begingroup$ You opened my eyes! Thanks so much! If I want implement , in image processing, a windowed truncated sinc filter, how I can do it? I can't imagine how it could be written in a programming language from scratch without the use of libraries. Can you help me? $\endgroup$
    – overflow'
    Sep 7, 2022 at 15:54
  • $\begingroup$ @overflow' hi thanks... Related answers exist on this site, please search through dsp.se $\endgroup$
    – Fat32
    Sep 7, 2022 at 21:24
  • $\begingroup$ Hi @fat32 !I have another doubt about the image resizing phase. Why if I only use truncated sinc in the Fourier domain (filter box as a matrix of ones - and zeros out of the dimensions of interest for scaling ) and avoid the decimation step I, after done inverse fourier trasform, get the image scaling ? $\endgroup$
    – overflow'
    Sep 14, 2022 at 14:49
  • $\begingroup$ For example: I have an image of 500x500 and I want obtain the same image but with new dimensions , for example 250x250 with decimation equal 2 . Then , I have been trasformed the image in frequency domain throught the fourier trasform , I multiply the fourier trasform of image with the fourier trasform of truncated sinc( box filter ) . Finally I have performed the inverse fourier trasform of this operation and I have obtained the image in spatial domain and the image returned by the operations above have 250x250 as dimension as I wanted but I have never done the decimation step ! $\endgroup$
    – overflow'
    Sep 14, 2022 at 14:50
  • $\begingroup$ Obviously, after doing the multiplication between the image and the kernel, since after this operation there are zeros due to the box filter, I have selected only the part where the values of the resulting matrix is different from zero. $\endgroup$
    – overflow'
    Sep 14, 2022 at 15:32
2
$\begingroup$
  1. Zeroing higher frequencies of the image in the Fourier domain (multiplying it with an ideal box filter) is equivalent to filtering the image in the time domain with a sinc function of infinite extent. Since you can't really filter with an infinite filter, when you transform back to the spatial domain, you will have artifacts in your image.

    So what you really need to filter with is a truncated sinc function, who's Fourier transform will be a non-ideal lowpass/box filter. This will give better results with fewer artifacts. A simple example filter would be a truncated sinc multiplied with a Hamming window (to reduce edge effects).

  2. As discussed above, you can use a truncated sinc as a lowpass filter. It does not downsample the image. But lowpass filtering is necessary before decimation in order to avoid aliasing. So downsampling is a two step process: lowpass filter, then decimate.

$\endgroup$
10
  • $\begingroup$ Thank you so much for your answer. I'm sorry for the delay in congratulating you. I have another doubt about the image resizing phase. Why if I only use truncated sinc in the Fourier domain (filter box as a matrix of ones - and zeros out of the dimensions of interest for scaling ) and avoid the decimation step I, after done inverse fourier trasform, get the image scaling ? $\endgroup$
    – overflow'
    Sep 14, 2022 at 14:40
  • $\begingroup$ For example: I have an image of 500x500 and I want obtain the same image but with new dimensions , for example 250x250 with decimation equal 2 . Then , I have been trasformed the image in frequency domain throught the fourier trasform , I multiply the fourier trasform of image with the fourier trasform of truncated sinc( box filter ) . Finally I have performed the inverse fourier trasform of this operation and I have obtained the image in spatial domain and the image returned by the operations above have 250x250 as dimension as I wanted but I have never done the decimation step ! $\endgroup$
    – overflow'
    Sep 14, 2022 at 14:48
  • $\begingroup$ Obviously, after doing the multiplication between the image and the kernel, since after this operation there are zeros due to the box filter, I have selected only the part where the values of the resulting matrix is different from zero. $\endgroup$
    – overflow'
    Sep 14, 2022 at 15:32
  • $\begingroup$ You could "crop" the Fourier transform of the image and then inverse Fourier transform to get the lowpass filtered and decimated image. Depending on your project, the results might look fine. However, to get better results, I'm suggesting in my answer that you're better off using a truncated, windowed sinc as the lowpass filter. This looks similar, but not identical to a "box filter" in the Fourier domain. So if you use it as a lowpass filter, it will not set values in the frequency domain to exactly zero. You can then decimate in the image domain. $\endgroup$
    – Gillespie
    Sep 14, 2022 at 17:06
  • $\begingroup$ Thanks. But, can I use another low pass filter instead of windowed sinc? Is there any reason about the use of sinc instead of another low pass filter (gaussian) ? $\endgroup$
    – overflow'
    Sep 15, 2022 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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