Here you can find the source of addGaussianNoise(double[][] d, double m, double v)
Parameter | Description |
---|---|
d | a parameter |
m | a parameter |
v | a parameter |
public static double[][] addGaussianNoise(double[][] d, double m, double v)
//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; } }