图像退化/复原过程模型
高斯噪声
PDF(概率密度函数)
生成高斯随机数序列
算法可参考<~wl/papers/07/csur07dt.pdf>
代码实现
1 double gaussrand() 2 { 3 static double V1, V2, S; 4 static int phase = 0; 5 double X; 6 7 if(phase == 0) { 8 do { 9 double U1 = (double)rand() / RAND_MAX; 10 double U2 = (double)rand() / RAND_MAX; 11 12 V1 = 2 * U1 - 1; 13 V2 = 2 * U2 - 1; 14 S = V1 * V1 + V2 * V2; 15 } while(S >= 1 || S == 0); 16 17 X = V1 * sqrt(-2 * log(S) / S); 18 } else 19 X = V2 * sqrt(-2 * log(S) / S); 20 21 phase = 1 - phase; 22 23 return X * 50; 24 }