7
$\begingroup$

I recently read that before downsampling an image, it should be blurred using a Gaussian Kernel. This way, the downsampled image is better than just picking a single pixel out of a NxN block or averaging over the block. After searching in this site as well as google, I didn't get any exact answer.

But there were questions on how to select $\sigma$ for blurring. Reading the answers on those posts, I learned that downsampling has to be done in accordance with sampling theorem. Downsampling without blurring causes aliasing effects.

  1. Can someone please explain why image has to be blurred before downsampling? I mean what is the exact relation to sampling theorem. What happens when an image is downsampled without blurring? I mean what are these aliasing effects? How can I notice them in the downsampled image?
  2. Why is Gaussian blurring better than Averaging over a block?

If you can give some examples of the images, I would be a lot grateful. Ans, I would appreciate all kind of answers, partial, intuitive, rigorous, anything.

Thank You!

$\endgroup$
13
$\begingroup$

An image "should not be blurred using a Gaussian Kernel" in general. This can be a safe bet for a lot of basic image processing needs, and a smoothing is almost mandatory when you want to control the information lost by the downsampling.

Blurring is (often, not always) another word for low-pass filtering. When an image contains high-frequency content (fast variations), downsampling without blurring can produce visually weird, annoying aliasing artifacts or moiré patterns. There is an example on wikipedia Aliasing: the original

brick wall patterns

and the downsampled, represented at the same size:

brick wall patterns with moiré

The ripples on the bottom right are low-frequency artifacts generated by a careless brute-force downsampling. A blurring would attenuate image sharpness, dim the borders between bricks, and reduce the apparent aliasing aspects.

The choice of appropriate blurring filters has a long history in image processing. Gaussian shapes have long been considered somehow optimal for different reasons for "theoretical" continuous images. Plus, it is both decreasing and symmetric in the space and the frequency domains. In the time domain, this means that faraway pixels have less influence. In the frequency domain, frequencies are reduced monotonously from low to high.

Since most images are discretized, reality is somewhat different. Since the Gaussian convolution used to be computationally expensive, early approximating filters were designed with short support, borrowed for instance from Pascal triangle. Later, fast recursive implementations were designed (Deriche, Shen, etc.)

I guess question 1) is answered. For question 2) simple averaging gives an equal weight to all pixels in the window. Hence, faraway pixels are given equal importance with respect to closer pixels, which is not optimal in regions where images exhibit weak stationarity, like trends, edges and textures.

$\endgroup$
5
  • 2
    $\begingroup$ Great answer! I’d add that simple averaging causes phase reversal for certain frequency bands, and has a much worse attenuation for the frequencies it is supposed to suppress. See here for a good example of phase reversal: crisluengo.net/index.php/archives/22 $\endgroup$ – Cris Luengo Oct 20 '18 at 16:30
  • 1
    $\begingroup$ Let me check and further read on phase reversal, I think I never thought about it that way $\endgroup$ – Laurent Duval Oct 20 '18 at 16:38
  • $\begingroup$ It comes about because, in the frequency domain, you have regions where the kernel is negative. $\endgroup$ – Cris Luengo Oct 20 '18 at 17:28
  • 1
    $\begingroup$ Gaussian kernel is separable, too, so it is computationally cheaper (You can do it on X and Y dimensions separately, and it retains its radially symmetric shape, unlike any other filter.) $\endgroup$ – endolith Mar 23 at 14:17
  • $\begingroup$ I indeed did not stressed the computational aspect enough, I will be more precise. The separability is not so simple IMO : optimized integer approximations, or oriented/skewed 2D Gaussian filters are not generally separable. And some recursive implementations (like the Canny-Deriche version) were a bit spikier at the tip $\endgroup$ – Laurent Duval Mar 23 at 16:00
8
$\begingroup$

According to (digital) sampling theorem, signals should be properly bandlimited, before they are (down) sampled.

A digital filter limits the bandwidth of the signal and makes it suitable for downsampling without aliasing.

A Gausssian kernel is very suitable as a lowpass filter, as it has a number of nice features. The Gaussian function is mathematically tractable. It has sufficient frequency attenuation. It has small time domain footprint. It has little noticeable artefacts. Therefore it's kind of a programmers choice in most typical image processing applications.

$\endgroup$

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.