数学基础:

什么是泊松噪声,就是噪声分布符合泊松分布模型。泊松分布(Poisson Di)的公

式如下:

关于泊松分布的详细解释看这里:http://zh.wikipedia.org/wiki/泊松分佈

关于高斯分布与高斯噪声看这里:

http://blog.csdn.net/jia20003/article/details/7181463

 二:程序实现

以前在图像加噪博文中现实的加高斯噪声,比较复杂。是自己完全实现了高斯随

机数的产生,这里主要是利用JAVA的随机数API提供的nextGaussion()方法来得

到高斯随机数。泊松噪声为了简化计算,Google到一位神人完成的C++代码于是

我翻译成Java的。

三:程序效果

滤镜源代码:

package com.gloomyfish.filter.study;  import java.awt.image.BufferedImage; import java.util.Random;  public class NoiseAdditionFilter extends AbstractBufferedImageOp {  public final static double MEAN_FACTOR = 2.0;  public final static int POISSON_NOISE_TYPE = 2;    public final static int GAUSSION_NOISE_TYPE = 1;   private double _mNoiseFactor = 25;     private int _mNoiseType = POISSON_NOISE_TYPE;      public NoiseAdditionFilter() {      System.out.println("Adding Poisson/Gaussion Noise");  }       public void setNoise(double power) {        this._mNoiseFactor = power;    }       public void setNoiseType(int type) {        this._mNoiseType = type;   }       @Override  public BufferedImage filter(BufferedImage src, BufferedImage dest) {        int width = src.getWidth();         int height = src.getHeight();         Random random = new Random();         if ( dest == null )             dest = createCompatibleDestImage( src, null );          int[] inPixels = new int[width*height];         int[] outPixels = new int[width*height];         getRGB( src, 0, 0, width, height, inPixels );         int index = 0;         for(int row=0; row<height; row++) {            int ta = 0, tr = 0, tg = 0, tb = 0;             for(int col=0; col<width; col++) {                index = row * width + col;                ta = (inPixels[index] >> 24) & 0xff;                 tr = (inPixels[index] >> 16) & 0xff;                 tg = (inPixels[index] >> 8) & 0xff;                 tb = inPixels[index] & 0xff;                 if(_mNoiseType == POISSON_NOISE_TYPE) {                  tr = clamp(addPNoise(tr, random));                     tg = clamp(addPNoise(tg, random));                     tb = clamp(addPNoise(tb, random));                 } else if(_mNoiseType == GAUSSION_NOISE_TYPE) {                   tr = clamp(addGNoise(tr, random));                     tg = clamp(addGNoise(tg, random));                     tb = clamp(addGNoise(tb, random));                 }                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;           }         }          setRGB( dest, 0, 0, width, height, outPixels );         return dest;   }       private int addGNoise(int tr, Random random) {      int v, ran;         boolean inRange = false;       do {            ran = (int)Math.round(random.nextGaussian()*_mNoiseFactor);            v = tr + ran;             // check whether it is valid single channel value           inRange = (v>=0 && v<=255);            if (inRange) tr = v;       } while (!inRange);         return tr;      }   public static int clamp(int p) {        return p > 255 ? 255 : (p < 0 ? 0 : p);   }       private int addPNoise(int pixel, Random random) {       // init:        double L = Math.exp(-_mNoiseFactor * MEAN_FACTOR);         int k = 0;         double p = 1;      do {            k++;          // Generate uniform random number u in [0,1] and let p ← p × u.             p *= random.nextDouble();      } while (p >= L);       double retValue = Math.max((pixel + (k - 1) / MEAN_FACTOR - _mNoiseFactor), 0);       return (int)retValue;   }  } 

转载文章请注明

转载于:https://blog.51cto.com/gloomyfish/1400317

图像处理之添加高斯与泊松噪声相关推荐

  1. python使用opencv对图像添加(高斯/椒盐/泊松/斑点)噪声

    导读 这篇文章主要介绍如何利用opencv来对图像添加各类噪声,原图 高斯噪声 高斯噪声就是给图片添加一个服从高斯分布的噪声,可以通过调节高斯分布标准差(sigma)的大小来控制添加噪声程度,sigm ...

  2. 数字图像处理——添加高斯噪声椒盐噪声

    数字图像处理--添加高斯噪声&椒盐噪声 本文链接:https://blog.csdn.net/u012936765/article/details/53200918 最近交了数图作业,mark ...

  3. MATLAB--数字图像处理 添加高斯噪声

    添加高斯噪声 概念 高斯噪声是指它的概率密度函数服从高斯分布(即正态分布)的一类噪声.如果一个噪声,它的幅度分布服从高斯分布,而它的功率谱密度又是均匀分布的,则称它为高斯白噪声.高斯白噪声的二阶矩不相 ...

  4. python高斯滤波和降噪_python添加高斯噪声和椒盐噪声,实现中值滤波和均值滤波,实现Roberts算子和Sobel算子...

    写在前面 HIT大三上学期视听觉信号处理课程中视觉部分的实验一,经过和学长们实验的对比发现每一级实验要求都不一样,因此这里标明了是2019年秋季学期的视觉实验一. 由于时间紧张,代码没有进行任何优化, ...

  5. 浅析“高斯白噪声”,“泊松噪声”,“椒盐噪声”的区别

    from:https://www.jianshu.com/p/67f909f3d0ce 在图像处理的过程中,一般情况下都进行图像增强,图像增强主要包括"空域增强"和"频域 ...

  6. 常见的噪声:高斯、泊松和椒盐噪声

    常见的噪声:高斯.泊松和椒盐噪声以及代码实现 转载的地址:https://www.jianshu.com/p/67f909f3d0ce 转载的地址:https://www.cnblogs.com/su ...

  7. python添加高斯噪声_使用Python-OpenCV向图片添加噪声(高斯噪声、椒盐噪声)

    在matlab中,存在执行直接得函数来添加高斯噪声和椒盐噪声.Python-OpenCV中虽然不存在直接得函数,但是很容易使用相关的函数来实现. 代码: import numpy as np impo ...

  8. 图像数据增强(平移,旋转,亮度变换,翻转,添加高斯噪声,缩放,裁剪)

    1.平移: import cv2 import tensorflow as tf import numpy as np from PIL import Image from skimage impor ...

  9. Python3|Opencv——添加高斯噪声Gauss Noise

    # -*- coding:utf-8 -*- #@Time: 2020/2/18 #@Author: EmmaHuu #@File: gauss_noise """ 添加 ...

最新文章

  1. Mac虚拟机安装windows教程--Parallels 5
  2. linux c指定相对路径,linux c编程,选用popen()得到一个相对路径的绝对路径
  3. Add Binary
  4. Linux设备驱动--块设备(二)之相关结构体
  5. 如何进行有效的数据治理,提升数据价值?
  6. Mac上IntelliJ IDEA设置类注释和方法注释带作者和日期
  7. html中隐藏单元格上边框,HTML table 标签边框问题(隐藏表格边框、单元格边框等)...
  8. java定时器异常,定时任务异常 高手进
  9. DSL 系列(1) - 扩展点的论述与实现
  10. 角动量守恒与陀螺力矩
  11. STC15单片机学习笔记1——STC15W4K56S4引脚功能整理说明
  12. C#实现百度AI-实时语音识别转写-附源码
  13. Web 全栈大会:万维网之父的数据主权革命
  14. 因果故事:偷不走的命运!
  15. Android小技巧 自动关闭输入法软键盘
  16. 计算机是如何跑起来的百度云,《程序是怎样跑起来的》(下)
  17. Python爬取淘宝图片
  18. 三维扫描体数据的VTK体绘制程序设计
  19. 全鲸董事长韩耀宁受邀出席第十九届中国科学家论坛,发表重要演讲
  20. Unity Tools 工具集合(新版)

热门文章

  1. 2019年软件测试现状调查
  2. 使用 NSUserDefaults 存储字典的一个坑
  3. 关于如何解决解决The SDK platform-tools version ((25.0.3)) is too old to check APIs compiled with API 26...
  4. SAS vs SSD各种模式下MySQL TPCC OLTP对比测试结果
  5. Drainage Ditches
  6. 机器学习(Part I)机器学习的种类
  7. 行业观察(一)| 从渠道为王到数据为王——浅谈服装零售企业的数字化转型...
  8. bzoj3396[Usaco2009 Jan]Total flow 水流*
  9. 在ThinkPHP中连接数据库
  10. 请教context:component-scan/和mvc:annotation-driven/的区别20