1、LoG算子的MATLAB运行程序A=imread('xibao.jpg');figure(1)imshow(A);title('原图');mask=[0,0,-1,0,0;0,-1,-2,-1,0;-1,-2,16,-2,-1;0,-1,-2,-1,0;0,0,-1,0,0];I=im2double(A);dx=imfilter(I,mask);grad=mat2gray(dx);BW=im2bw(grad,0.41);figure(2)imshow(BW);title('log算子处理')2、Sobel算子的MATLAB运行实验结果程序:A=imread('xibao.jpg');imshow(A);title('原图');y_mask=[-1,-2,-1;0,0,0;1,2,1];x_mask=y_mask';I=im2double(A);dx=imfilter(I,x_mask);dy=imfilter(I,y_mask);grad=sqrt(dx.*dx+dy.*dy);grad=mat2gray(grad);level=graythresh(grad);;BW=im2bw(grad,level);figure,imshow(BW);title('Sobel算子处理')3、改进的Sobel算子的MATLAB运行实验结果程序:A=imread('xibao.jpg');imshow(A);title('yuantu');mask1=[-1,-2,-1;0,0,0;1,2,1];mask2=[-2,-1,0;-1,0,1;0,1,2];mask3=[-1,0,1;-2,0,2;-1,0,1];mask4=[0,1,2;-1,0,1;-2,-1,0];mask5=[1,2,1;0,0,0;-1,-2,-1];mask6=[2,1,0;1,0,-1;0,-1,-2];mask7=[1,0,-1;2,0,-2;1,0,-1];mask8=[0,-1,-2;1,0,-1;2,1,0];I=im2double(A);d1=imfilter(I,mask1);d2=imfilter(I,mask2);d3=imfilter(I,mask3);d4=imfilter(I,mask4);d5=imfilter(I,mask5);d6=imfilter(I,mask6);d7=imfilter(I,mask7);d8=imfilter(I,mask8);dd=max(abs(d1),abs(d2));dd=max(dd,abs(d3));dd=max(dd,abs(d4));dd=max(dd,abs(d5));dd=max(dd,abs(d6));dd=max(dd,abs(d7));dd=max(dd,abs(d8));grad=mat2gray(dd);level=graythresh(grad);BW=im2bw(grad,level);figure,imshow(BW);title('八方向的Sobel')BB=grad;FW=median(BB(:))/0.31B=BB.*BB;B=sum(B(:));FX=sqrt(B/256^2);FS=sqrt(max(FX^2-FW^2,0));T=sqrt(2)*FW^2/FS;grad=mat2gray(BB);BW2=im2bw((grad),T);figure,imshow(BW2);title('改进的Sobel算子处理');4、各种算子综合的MATLAB处理:程序I=imread('xibao.jpg');%读取图像I1=im2double(I);%将彩图序列变成双精度I2=rgb2gray(I1);%将彩色图变成灰色图[thr,sorh,keepapp]=ddencmp('den','wv',I2);I3=wdencmp('gbl',I2,'sym4',2,thr,sorh,keepapp);%小波除噪I4=medfilt2(I3,[99]);%中值滤波I5=imresize(I4,0.4,'bicubic');%图像大小BW1=edge(I5,'sobel');%sobel图像边缘提取BW2=edge(I5,'roberts');%roberts图像边缘提取BW3=edge(I5,'prewitt');%prewitt图像边缘提取BW4=edge(I5,'log');%log图像边缘提取BW5=edge(I5,'canny');%canny图像边缘提取h=fspecial('gaussian',5);%高斯滤波BW6=edge(I5,'zerocross',[],h);%zerocross图像边缘提取figure;subplot(2,3,1);%图划分为两行六幅图,第一幅图imshow(I2);%绘图figure;subplot(2,3,1);imshow(BW1);title('Sobel算子');subplot(2,3,2);imshow(BW2);title('Roberts算子');subplot(2,3,3);imshow(BW3);title('Prewitt算子');subplot(2,3,4);imshow(BW4);title('log算子');subplot(2,3,5);imshow(BW5);title('canny算子');