If you code Computer Graphics stuff, or if you work in any field of science, then you are necessarily familiar with the Gaussian function (a.k.a. Normal distribution, Gaussian point-spread function, …).

The formulations below, where s=sigma is the standard deviation, assume that the mean m is 0:

Gaussian 1D/2D formulation The Gaussian function is commonly used as a convolution kernel in Digital Image Processing to blur an image. Computing a convolution is generally very slow, so choosing a convolution kernel that is as small as possible is always desirable.

The image below depicts a canonical Gaussian function where m=0 and s=1 in the range x=[-4..+4]. Changing the mean shifts the function to the left or right, and changing the standard deviation stretches or compresses the bell-shaped curve, but always leaving its surface (integral in [-INF..+INF]) unaffected and equal to 1.

Gaussian 1D The red, green, and blue regions are the intervals of radius sigma, 2·sigma, and 3·sigma around the mean. Interestingly, the red region comprises around 68% of the total integral of the Gaussian. The red+blue regions comprise around 95%, and the red+blue+green regions comprise more than 97% of the total.

(Wikipedia has a fantastic explanation of this in the Percentile page).

In other words, ignoring a Gaussian function beyond a radius of 3·sigma still leaves you with more than 97% of its total information.

In 2D, the Gaussian function can be described as the product of two perpendicular 1D Gaussians, and due to radial symmetry, the same principle applies:

Gaussian 2D This knowledge is very valuable when building a Gaussian-based blur convolution kernel.

As a summary:

The radius of a Gaussian kernel can be as tight as ceil(3·sigma).

Say that you intend to do a Gaussian blur of sigma=5 pixels. The optimal kernel dimensions would be [(15+1+15)x(15+1+15)] => [31x31].

The difference between using an infinite or a size-limited Gaussian kernel is negligible to the naked eye. The animated image below presents two Gaussian convolutions of the same sigma=5. One of them uses a kernel of radius 3·sigma=15, and the other one uses an infinite radius. As you can see, the difference can only be slightly noticed around areas of very high power. The base image used for this example intentionally features a very high dynamic range of approx. [0..625]. More on convolutions soon…

# More on coding art (hair and fur)

I feel fortunate to work on a field where not only I deal on a daily basis with plenty of algorithms worth visualizing, but my job itself is to develop algorithms -to- visualize. This is, the end goal of the algorithms I work with is to visualize (photo-real) stuff.

For example, here’s a visualization of the highly efficient fiber-field rendering routines (hair/fur) that I’ve been working on during the past months. This image was rendered by Erwann Loison in Arion 3. But, if you want to put it this way, an Arion render is nothing but a visualization of the light simulation algorithms that are running inside. Tennis ball on a clay court Now, here’s a much more spartan visualization of some of the routines involved in Arion’s hair/fur rendering. This is an image taken from the RCSDK Unit Testing system. It visualizes some of my custom ray-to-primitive intersection routines (e.g., infinite planes, spheres, cylinders, cones, and connectable fiber (hair) segments).

Ray-to-primitive intersections 