I=imread('C:\Users\Administrator\Desktop\孔雀1.jpg');
J1=imnoise(I,'gaussian',0,0.0005);
J=rgb2gray(J1);
subplot(2,3,1);imshow(I);
title('原始图像');
subplot(2,3,2); imshow(J);
title('加入高斯噪声之后的图像');
K1=filter2(fspecial('average',1),J)/255;
K2=filter2(fspecial('average',5),J)/255;
K3=filter2(fspecial('average',7),J)/255;
K4= filter2(fspecial('average',9),J)/255;
subplot(2,3,3);imshow(K1);
title('改进后的图像1');
subplot(2,3,4); imshow(K2);
title('改进后的图像2');
subplot(2,3,5);imshow(K3);
title('改进后的图像3');
subplot(2,3,6);imshow(K4);
title('改进后的图像4');
img=imread('C:\Users\Administrator\Desktop\孔雀1.jpg');
imggray=rgb2gray(img);
imggrayfilt=filter2(fspecial('average',1),J)/255;
figure(1)
imshow(imggray);
figure(2)
imhist(imggrayfilt);
figure(3)
imshow(imggrayfilt);
imgbw = im2bw(imggrayfilt,graythresh(imggrayfilt));
figure(4)
imshow(imgbw);
I=imread('C:\Users\Administrator\Desktop\孔雀1.jpg');% 提取图像
I=rgb2gray(I);
BW1=edge(I,'sobel'); %用SOBEL算子进行边缘检测
BW2=edge(I,'roberts');%用Roberts算子进行边缘检测
BW3=edge(I,'prewitt'); %用prewitt算子进行边缘检测
BW4=edge(I,'log'); %用log算子进行边缘检测
BW5=edge(I,'canny'); %用canny算子进行边缘检测
%h=fspecial('gaussian',5);
BW6=edge(I,'canny');
figure(1);
subplot(2,3,1), imshow(BW1);
title('sobel edge check');
subplot(2,3,2), imshow(BW2);
title('roberts edge check');
subplot(2,3,3), imshow(BW3);
title('prewitt edge check');
subplot(2,3,4), imshow(BW4);
title('log edge check');
subplot(2,3,5), imshow(BW5);
title('canny edge check');
subplot(2,3,6), imshow(BW6);
title('gasussian&canny edge check');%此为用高斯滤波后Canny算子边缘检测结果
figure(2);
%Egray = uint8(edge(I,'canny'));
%for i = 1:300
% for j = 1:300
% if Egray(i,j)==0
% I(i,j)=0;
% end
% end
%%end
%imshow(I);