给图像加高斯噪声和椒盐噪声(不使用自带函数)matlab实现
2017-10-25 21:55
447 查看
图像画面中的噪声,大致可以分为两类:高斯噪声和椒盐噪声。在这里,我们先看下图像中两种噪声各自的特征。
椒盐噪声:噪声幅值基本相同,但出现位置随机。
高斯噪声:图像中每一点都存在噪声,但幅值是随机分布的。
用matlab给一个图像加高斯噪声:
image=imread('E:\image\pepper.jpg');
[width,height,z]=size(image);
if(z>1)
image=rgb2gray(image);
end
figure(2);
subplot(1,2,1);
imshow(image);
title('原图');
av=0;
std=0.1;
u1=rand(width,height);
u2=rand(width,height);
x=std*sqrt(-2*log(u1)).*cos(2*pi*u2)+av;
result1=double(image)/255+x;
result1=uint8(255*result1);
subplot(1,2,2);
imshow(result1);
title('加高斯噪声后');
[width,height,z]=size(image);
if(z>1)
image=rgb2gray(image);
end
result2=image;
figure(2);
subplot(1,2,1);
imshow(image);
title('原图');
k1=0.1;
k2=0.3;
a1=rand(width,height)<k1;
a2=rand(width,height)<k2;
result2(a1&a2)=0;
result2(a1& ~a2)=255;
subplot(1,2,2);
imshow(result2);
title('加椒盐噪声后');
椒盐噪声:噪声幅值基本相同,但出现位置随机。
高斯噪声:图像中每一点都存在噪声,但幅值是随机分布的。
用matlab给一个图像加高斯噪声:
image=imread('E:\image\pepper.jpg');
[width,height,z]=size(image);
if(z>1)
image=rgb2gray(image);
end
figure(2);
subplot(1,2,1);
imshow(image);
title('原图');
av=0;
std=0.1;
u1=rand(width,height);
u2=rand(width,height);
x=std*sqrt(-2*log(u1)).*cos(2*pi*u2)+av;
result1=double(image)/255+x;
result1=uint8(255*result1);
subplot(1,2,2);
imshow(result1);
title('加高斯噪声后');
下面是加入椒盐噪声:
image=imread('E:\image\pepper.jpg');[width,height,z]=size(image);
if(z>1)
image=rgb2gray(image);
end
result2=image;
figure(2);
subplot(1,2,1);
imshow(image);
title('原图');
k1=0.1;
k2=0.3;
a1=rand(width,height)<k1;
a2=rand(width,height)<k2;
result2(a1&a2)=0;
result2(a1& ~a2)=255;
subplot(1,2,2);
imshow(result2);
title('加椒盐噪声后');
相关文章推荐
- 使用matlab自带的卷积码编解码函数实现咬尾卷积码
- MATLAB GUI ,2,使用MATLAB的函数来实现MATLAB GUI,part 5,imshow绘图方式以及主辅图像缓存
- 图像放缩 (matlab实现,不用自带的函数)
- MATLAB GUI ,2,使用MATLAB的函数来实现MATLAB GUI,part 1,图像、按钮和坐标轴
- MATLAB GUI ,2,使用MATLAB的函数来实现MATLAB GUI,part 4,小游戏
- MATLAB自带的svm实现函数与libsvm差别小议
- Windows下Matlab使用G++ DLL实现图像处理
- opencv 旋转图像函数实现 等同于matlab里的rotate() (注:旋转后图像变大,超出部分填为黑色)
- Matlab中使用varargin来实现参数可变的函数
- Matlab中使用varargin来实现参数可变的函数
- matlab自带滤波器函数小结(图像处理)
- [数字图像处理]常见噪声的分类与Matlab实现
- matlab自带函数实现高斯滤波
- MATLAB自带的svm实现函数与libsvm差别小议
- MATLAB自带的svm实现函数与libsvm差别
- MATLAB GUI ,2,使用MATLAB的函数来实现MATLAB GUI,part 3,全局变量,计时器和状态机
- Matlab中使用varargin来实现参数可变的函数
- C#图像添加高斯噪声和椒盐噪声及图像恢复
- 使用MATLAB在图像中选择矩形框区域的操作函数即过程
- 使用双线性插值法放大图像(matlab实现)