[問題] 高斯白雜訊與高斯雜訊的差別

看板C_Sharp (C#)作者 (阿盧)時間8年前 (2016/09/24 11:56), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
初次學習影像處理,在網上看到對影像加入高斯噪音(雜訊),想要變成加入高斯"白"雜訊 的話,應該修改什麼呢?因為不知兩者有何差別希望各位大大指導謝謝! 以下為看見的程式碼~ /// <summary> /// 对一幅图形进行高斯噪音处理。 /// </summary> /// <param name="img"></param> /// <param name="u">数学期望</param> /// <param name="a">方差</param> /// <returns></returns> static public Bitmap goss_noise(Image img, double u, double a) { int width = img.Width; int height = img.Height; Bitmap bitmap2 = new Bitmap(img); Rectangle rectangle1 = new Rectangle(0, 0, width, height); PixelFormat format = bitmap2.PixelFormat; BitmapData data = bitmap2.LockBits(rectangle1, ImageLockMode.ReadWrite, format ); IntPtr ptr = data.Scan0; int numBytes = width * height * 4; byte[] rgbValues = new byte[numBytes]; Marshal.Copy(ptr, rgbValues, 0, numBytes); Random random1 = new Random(); for (int i = 0; i < numBytes; i += 4) { for (int j = 0; j < 3; j++) { double z; z = random1.NextDouble() - 0.5 + u; double pz = gossp(z, u, a); double r = random1.NextDouble(); // Debug.WriteLineIf(pz < 0.1, string.Format("z={0}\tpz={1}\tr={2}", z,pz,r)); if (r <= pz) { double p = rgbValues[i + j]; p = p + z * 128; if (p > 255) p = 255; if (p < 0) p = 0; rgbValues[i + j] = (byte)p; } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.217.167.158 ※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1474689398.A.9DD.html
文章代碼(AID): #1NvVbsdT (C_Sharp)
文章代碼(AID): #1NvVbsdT (C_Sharp)