# What is the optimal radius of gaussian distribution for determining pixel colour?

Using a gaussian distribution of points on an image plane to calculate a pixel value, what radius/standard deviation will give the most information in the final image? Too large a radius gives a blurred image, and too small a radius neglects information that is smaller than a pixel so that it does not contribute to the final image. Where is the optimal compromise? Is there a single answer to this question or are there circumstances under which it can vary?

I'm thinking of this in relation to raytracing but I imagine it will apply equally to things like downsizing an image. Where the answers would differ, I am interested in what applies when sampling a continuous image plane, so that the positions of pixels in a larger image cannot be used to determine an optimal radius.

I'm not sure that there's a truly optimal radius—it's going to be a subjective matter based on what the image looks like. As you say, too large a radius results in blurring and too small a radius results in aliasing.

I like to set sigma = 0.5 px, so that the overall radius is about 1.5 px (since the Gaussian has the majority of its weight within ±3 sigma of its mean). In my experience that gives a good trade-off between blurring and aliasing, but that's just my taste, not based on any objective considerations.

By the way, as part of a blog post on antialiasing I wrote last year (which was based on an answer I posted on the previous incarnation of this site!), I tested a variety of antialiasing kernels against a synthetic test image and came out with 0.5 px Gaussian as my subjective favorite.

• I remember that answer last time round :) (I was githubphagocyte back then). Interesting to see it expanded into a blog post. Commented Aug 5, 2015 at 21:01

Imagine that one is rendering a picture of a flat floor with a uniform black and white checkerboard pattern that extends to the horizon; the checkers are large enough that they should be clearly visible at points near the camera but not large enough to be distinguishable near the horizon.

Near the horizon, the floor should simply appear as uniform gray. Near the camera, the checkers should appear distinct. Between the camera and the horizon the appearance of the floor must somehow transition between those two extremes.

If the scene is rendered a spacial filter that has a very sheep cut-off, there will be a certain distance where the floor goes from being checkered to being gray. If one uses a shallower filter, the transition will be much more gradual, but things near the original "cut-off" distance will be less sharp than they would have been otherwise.

If one were to add a "wall" or crop the scene to hide the distant parts of the floor, such that there was no need to have any parts of the checkered floor blurred to gray, the best results would be obtained by using the steepest filter, yielding the sharpest image. Using a shallower filter would give up image sharpness for the purpose of preventing a nasty transition that wasn't going to be visible anyway.

Figuring out what kind of filtering to use thus requires that one know something about the spacial frequency content of the information to be displayed. If the image contains nothing of interest that would approach Nyquist, using a steep filter will produce the sharpest results. If, however, image content exceeds Nyquist, using a gradual filter will avoid ugly "transitions". No single approach will be optimal for all cases.

In my opinion and experience i don't think there exists an univocal answer... since basically in literature you can easily find example of adaptive filters too (i.e. of variable size).

I think the actual answer should be related to the both context of applications (i.e. hardware or sofware, real time or not) and kind of scene you're going to synthesize (some scenes usually involves different kind of aliasing when are synthetized (i use this general term on purpose)). Basically computer graphics is the study of algorithms and data structure for image synthesis, and such definition isn't stricly related to any kind of application.

Of course an important factor is even the goal to be achieved by a filtering process (i.e. not necessary an excessive blurring could be bad...).

If you're speaking of "nice to see" i think you could agree with me when i say that there's no specific measure of "pleasant image".