how to build a Gaussian mask?

Hi everybody,

I intend to do following but no idea has come across my mind yet.

b) build an opaque mask
c) control the transparency (alpha channel) of the mask in an arbitrary point of the mask according to a 2D Gaussian profile. That is, the alpha channel of the mask should smoothly go from min = 0 = fully transparent (in the center of the Gaussian) to max = 1 = fully opaque (outside the Gaussian).
e) once the punctured mask is built, apply it to the previously loaded image

The point is: I don’t know how to build 2D Gaussian mask, make it work on alpha channel and then how to apply it on the image.

Any idea?
Thanks a lot

Well a Gaussian bell in 3d is symmetric and therefore separable as a kernel so you only need to consider the 2d case. The curve goes as G(x) = exp(-s x) = 1 / exp(s x), so it has a max at G(0)=1 and a min at G(inf) = 0. Clearly infinity isn’t much use so you’d want to pick a value for s that brings it close to 0 for a given x. You could pick a small epsilon say to equate with G then take the log of both sides to find a reasonable s.

Consider this Gaussian function:

Notice that the function values are always very small at G(±3Sigma), so 3Sigma is usually a good estimation of one half of the kernel size. This rule is often used in image processing.

The Gaussian mask can be built from the Gaussian function. Example:

That is informative Eoise. But as you mentioned 3sigma, if a 33 mask is to be made from scratch what should be this sigma?

3*sigma is the distance from the center of a kernel where the function value is considered almost zero. For a 3x3 mask, the distance between the center and the leftmost element is obviously one, so the sigma should be one third at most. Feel free to use a little higher value because you often need as much blurring as possible in eye-candy computer graphics. However, if you have an image processing algorithm that relies on a mathematical correctness, a large enough kernel is required.