噪声,简而言之就是图像中随机出现的灰度变化大的离散的像素点。噪声可能来自于图像采集,量化等过程,也可能产生于图像传送过程中,具有离散性和随机性等特点。
1.噪声的分类
根据噪声服从的分布对其进行分类:
(1)高斯噪声(Gaussian white noise):最普通的噪声,噪声信号随机分布,没有规律;
(2)泊松噪声(Poisson noise):常在亮度非常小时出现,或在高倍电子放大线路中出现,噪声信号服从Poisson分布。
(3)颗粒噪声:白噪声的一种,图像中显示明显的颗粒,最常见的便是椒盐噪声(salt & pepper noise)。
2.函数imnoise
在Matlab中有一个重要的噪声生成函数imnoise,其常见语法说明如下:
语法 | 参数说明 |
---|---|
J = imnoise(I,type) | 按照给定类型添加图像噪声给图像I |
J = imnoise(I,type,parameters) | parameters泛指可以添加的参数,类型不同,参数自然不同 |
J = imnoise(I,‘gaussian’,m,v) | 添加高斯白噪声,均值为m,方差为v。default状态下,m = 0,v = 0.01 |
J = imnoise(I,‘localvar’,V) | 添加零均值,局部方差为V的高斯白噪声给图像I。V是与I尺寸相同的数组 |
J = imnoise(I,‘poisson’) | 添加Poisson噪声给图像I |
J = imnoise(I,‘salt & pepper’,d) | 添加椒盐噪声给图像I,d是噪声密度。这将影响d * numel(I)个像素。default状态下,d = 0.05 |
J = imnoise(I,‘speckle’,v) | 添加乘法噪声给图像I,v是方差。机理:J = I + n * I,n是均匀分布的随机噪声。在default状态下,v = 0.04 |
注意:函数imnoise在将输入图像添加噪声的过程中,若输入图像的数据类型是double型,范围为[0,1],噪声‘gaussian’,‘poisson’,‘speckle’的参数类型总是被指定;若输入图像的数据类型是uint8或uint16,imnoise函数先将图像数据类型转化成double类型,添加指定的参数,最后输出时又将数据类型还原成原输入图像数据类型。
参数说明:对于多数噪声类型,输入图像I的数据类型可以是uint8,uint16,int16,single或double。输出图像的数据类型和输入图像的数据类型相同。若I超过了2维,则将其作为多维图像处理,而不是RGB图像处理。
3.imnoise函数使用示例
代码:
I = imread('eight.tif');
subplot(221),imshow(I);
title('Original image');
J = imnoise(I,'gaussian',0,0.02);%添加高斯白噪声,均值0,方差0.02
subplot(222),imshow(J);
title('Gaussian');
K = imnoise(I,'salt & pepper',0.03);%添加椒盐噪声,密度0.03
subplot(223),imshow(K);
title('Salt & Pepper');
L = imnoise(I,'poisson');%添加Poisson噪声
subplot(224),imshow(L);
title('Poisson');
运行截图:
观察运行结果可知:椒盐噪声的强度最大,但噪声分布最稀松,高斯噪声和泊松噪声分布比较密,但高斯噪声的强度比泊松噪声的强度大。