Java Gauss gaussian(int size, double sigma)

Here you can find the source of gaussian(int size, double sigma)

Description

gaussian

License

Open Source License

Declaration

public static float[] gaussian(int size, double sigma) 

Method Source Code

//package com.java2s;
/*// ww  w . j a v a 2s  . c  o  m
 * Copyright (C) 2011 Ren? Jeschke <rene_jeschke@yahoo.de>
 * See LICENSE.txt for licensing information.
 */

public class Main {
    public static float[] gaussian(int size, double sigma) {
        final float[] g = new float[size];
        final int s2 = size / 2;
        float sum = 0;

        for (int i = 0; i < size; i++) {
            final double x = (double) (i - s2) / (double) s2;
            final float v = (float) Math.exp(-(x * x)
                    / (2.0 * sigma * sigma));
            sum += v;
            g[i] = v;
        }

        for (int i = 0; i < size; i++)
            g[i] /= sum;

        return g;
    }
}

Related

  1. gaussian(double t)
  2. gaussian(double x, double sigma)
  3. gaussian(double[] d, double sigma, double mean)
  4. gaussian(double[][] A, double[] b)
  5. gaussian(float x, float mean, float sd)
  6. gaussianBlur(int[][] pixels, float sigma)
  7. gaussianDensity(double x, double mean, double standardDeviation)
  8. gaussianDerivative(double x)
  9. gaussianFilter(float[] weights, float sigma)