`Gaussian`

class generates KZPKernel for blurring
* an image.
* * The Gaussian smoothing operator is a 2-D convolution operator that * is used to `blur' images and remove detail and noise. In this sense * it is similar to the mean filter, but it uses a different kernel * that represents the shape of a Gaussian (`bell-shaped') hump. *

* The equation of Gaussian distribution in 2 dimensions: *

*

* When applied in two dimensions, this formula produces a surface whose * contours are concentric circles with a Gaussian distribution from the * center point. Pixels where this distribution is non-zero are used to * build a convolution matrix, which is applied to the original image. * Each pixel's value is set to a weighted average of that pixel's * neighborhood. The original pixel's value receives the heaviest weight * (having the highest Gaussian value), and neighboring pixels receive * smaller weights as their distance to the original pixel increases. * This results in a blur that preserves boundaries and edges better * than other, more uniform blurring filters; see also scale-space * implementation. * @author Andrzej Jóźwiak * @author Stanisław Walczak * @author Konrad Jojczyk * @version 0.002, 29/06/07 * @since JDK1.5 */ public class Gaussian { /** * The size stores default kernel size. */ protected int size = 5; /** * The sigma stores value used in computing * the Gaussian distribution. */ protected float sigma = 50.0f; /** * The origin stores kernel's origin point used * in further computing. */ protected Point origin = new Point(1,1); /** * This method is an implementation of computing the * Gaussian distribution for given point in image. * * @param sigma The standard deviation of the distribution. * @param x Pixel's x coordinate. * @param y Pixel's y coordinate. * @return Computed value of Gaussian distribution. */ protected float gaussian(float sigma, int x, int y){ float g = 0; //for faster preforming we compute this only once: float sigmasqr = sigma*sigma; float func = 1f/(2f * (float)Math.PI * sigmasqr); for(float ySubPixel = y - 0.5f; ySubPixel < y + 0.55f; ySubPixel += 0.1f){ for(float xSubPixel = x - 0.5f; xSubPixel < x + 0.55f; xSubPixel += 0.1f){ g += (float)((func * Math.pow(Math.E, -(xSubPixel * xSubPixel + ySubPixel * ySubPixel)/(2 * sigmasqr)))); } } return g; } /** * This method generates appropriate KZPKernel with * generated Gaussian blurring values. * @return KZPKernel with computed distributions. */ public KZPKernel getFilterKernel() { float[] values = new float[size*size]; //we generate the kernel for(int j=0;j* G(u,v) = e^(-(u^2+v^2)/(2*sigma^2))/2*pi*sigma^2 *