matlab给图像加噪声比较实用的方法---函数imnoise介绍

近期写论文的时候要用到给图像加噪声,就在网上百度了一下,发现其中的一篇博客写的很好,就转载过来了,这里我主要转载了博主的第三部分imnoise函数。如果需要更详细的内容,请到原博主博客浏览。希望对大家有所帮助。
博客原文转自 https://blog.csdn.net/liuyingying0418/article/details/79432962

  1. imnoise()
    官方文档说明为:
    J = imnoise(I,’gaussian’,M,V) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
    也就是说M表示均值,V表示方差。
    那么将添加噪声的代码改为:

distImg = imnoise(origImg, ‘gaussian’, 0, 10的2次方除以255^2);
可得到:
var =
99.3884
std =
9.9694
mean =
-0.0197
Note : The mean and variance parameters for ‘gaussian’, ‘localvar’, and ‘speckle’ noise types are always specified as if the image were of class double in the range [0, 1]. If the input image is of class uint8 or uint16, the imnoise function converts the image to double, adds noise according to the specified type and parameters, and then converts the noisy image back to the same class as the input.
此处解释一下,原始图像origImg是uint8的灰度图像,灰度值范围为[0,255],故imnoise函数在处理时会将图像先转换为[0,1],然后按照所给的均值和方差添加噪声,最后再将图像转换到[0,255]的范围内,因此参数设置尤其要注意,如果所给的图像是uint8时,所给的均值和方差必须是在[0,1]的范围内,也就是说要归一化,不然直接给100的方差时,imnoise函数会将图像归一化,然后按照方差100来添加噪声,这样原先的图像就给淹没了,反而变成了噪声为主导

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值