图像处理中将高斯噪声换成椒盐噪声

图像边缘处理中几种边缘检测算子比较
如何将代码中的高斯噪声换成椒盐噪声

I=imread('daitu.jpg');%载入原图像
figure;
subplot(1,3,1);
imshow(I),title('原图像')%显示原图像
I1=rgb2gray(I);%将原图像进行灰度化
subplot(1,3,2);
imshow(I1),title('灰度图像')%显示灰度图像
I2=imnoise(I1, 'gaussian',0,0.01);%对灰度图像加入均值为0,方差为0.01的高斯噪声
subplot(1,3,3);
imshow(I2),title('加高斯噪声后的图像')%显示加噪声后的图像

figure;
BW1=edge(I1,'roberts','both');%用Roberts算子检测边缘
subplot(2,3,1);
imshow(BW1),title('roberts算子')
BW2=edge(I1,'prewitt','both');%用Prewitt算子检测边缘
subplot(2,3,2);
imshow(BW2),title('prewitt算子')

tic
BW3=edge(I1,'sobel','both');%用Sobel算子检测边缘
toc
disp(['运行时间: ',num2str(toc)]);
subplot(2,3,3);
imshow(BW3),title('sobel算子')
BW4=edge(I1,'log','both');%用LOG算子检测边缘
subplot(2,3,4);
imshow(BW4),title('log算子')
BW5=edge(I1,'canny','both');%用Canny算子检测边缘
subplot(2,3,5);
imshow(BW5),title('canny算子')

figure;
BW6=edge(I2,'roberts','both');%用Roberts算子检测边缘
subplot(2,3,1);
imshow(BW6),title('roberts算子抗噪声性能检测')
BW7=edge(I2,'prewitt','both');%用Prewitt算子检测边缘
subplot(2,3,2);
imshow(BW7),title('prewitt算子抗噪声性能检测')
BW8=edge(I2,'sobel','both');%用Sobel算子检测边缘
subplot(2,3,3);
imshow(BW8),title('sobel算子抗噪声性能检测')
BW9=edge(I2,'log','both');%用LOG算子检测边缘
subplot(2,3,4);
imshow(BW9),title('log算子抗噪声性能检测')
BW10=edge(I2,'canny','both');%用Canny算子检测边缘
subplot(2,3,5);
imshow(BW10),title('canny算子抗噪声性能检测')

figure;
subplot(2,5,1);imshow(BW1),title('roberts算子')
subplot(2,5,2);imshow(BW2),title('prewitt算子')
subplot(2,5,3);imshow(BW3),title('sobel算子')
subplot(2,5,4);imshow(BW4),title('log算子')
subplot(2,5,5);imshow(BW5),title('canny算子')

subplot(2,5,6);imshow(BW6),title('roberts算子抗噪声性能检测')
subplot(2,5,7);imshow(BW7),title('prewitt算子抗噪声性能检测')
subplot(2,5,8);imshow(BW8),title('sobel算子抗噪声性能检测')
subplot(2,5,9);imshow(BW9),title('log算子抗噪声性能检测')
subplot(2,5,10);imshow(BW10),title('canny算子抗噪声性能检测')