Java Gaussian addGaussianNoise(double[][] d, double m, double v)

Here you can find the source of addGaussianNoise(double[][] d, double m, double v)

Description

Matlab compatible see code of imnoise in Matlab

License

Open Source License

Parameter

Parameter Description
d a parameter
m a parameter
v a parameter

Declaration

public static double[][] addGaussianNoise(double[][] d, double m,
        double v) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    /**/*www.  j  a va2  s  .c  om*/
     * Matlab compatible see code of imnoise in Matlab
     *
     * @param d
     * @param m
     * @param v
     * @return
     */
    public static double[][] addGaussianNoise(double[][] d, double m,
            double v) {
        double[][] r = new double[d.length][d[0].length];
        Random rnd = new Random();
        for (int i = 0; i < d.length; i++) {
            for (int j = 0; j < d[0].length; j++) {
                r[i][j] = Math.round(m + d[i][j] + rnd.nextGaussian()
                        * Math.sqrt(v));
            }
        }
        return r;
    }
}

Related

  1. gaussian()
  2. getGaussian()
  3. getGaussian(double aMean, double aVariance)
  4. hashToGaussian(int h)