The best, and most sophisticated type of blur is known as a Gaussian blur. This simulates quite well the view a nearsighted person has without his or her glasses. The primary difficulty with programming a Gaussian blur is determining the convolution mask. A function must be used that gives an output similar to the one in figure 1.2 below.
The function in figure 1.2 gives a very good blur because the immediately surrounding pixels have an important effect when the averages are calculated, while the pixels at a greater distance have very little effect. The function used in the Java applet is:
The above function, you will notice, only gives a two dimensional plot, and to perform a Gaussian blur, a three dimensional plot is needed. To produce the 3D plot, we essentially spun the 2D plot around in a 360 degree circle pattern, yielding the three dimensional result. The weight of each pixel was determined as a percentage of the entire convolution array, and the color of each pixel was determined by adding the weighted pixels found using the array. Considering that the images each contain 40,000 pixels, and the convolution array can be as large as 1600 values, the final weighting can involve as many as 64 million pixels in the applet!!!
For further experimentation, please visit the Java page: