2、tt算子<一阶微分算子)及Laplacian算子<二阶微分算子)边缘图像,实现代码如下:b5E2RGbCAP5/5roberts1=[1,0。0,1]。roberts2=[0,1。-1,0]。prewitt1=[-1,0,1。-1,0,1。-1,0,1]。prewitt2=[1,1,1。0,0,0。-1,-1,-1]。sobel1=[-1,0,1。-2,0,2。-1,0,1]。sobel2=[1,2,1。0,0,0。-1,-2,-1]。laplacian1=[0,-1,0。-1,4,-1。0,-1,0]。laplacian2=[-1,-1,-1。-1,8,-1。-1,-1,-1]。f=i
3、mread('C:UsersAdministratorDesktoptungsten.tif'>。p1EanqFDPwf=double(f(1:100,1:100>>。f1=imfilter(f,roberts1>。f2=imfilter(f,roberts2>。roberts_f=max(abs(f1>,abs(f2>>。f1=imfilter(f,prewitt1>。f2=imfilter(f,prewitt2>。prewitt_f=max(abs(f1>,abs(f2>>。f1=imfilter(f,sobel1>。f2=imfilter(f,sobel2>。sobel_f
4、=max(abs(f1>,abs(f2>>。f1=imfilter(f,laplacian1>。f2=imfilter(f,laplacian2>。laplacian_f=max(abs(f1>,abs(f2>>。figure,subplot(2,2,1>,imshow(roberts_f,[]>,title('roberts边缘检测图像'>DXDiTa9E3dsubplot(2,2,2>,imshow(prewitt_f,[]>,title('prewitt边缘检测图像'>RTCrpUDGiTsubplot(2,2,3>,imshow(sobel_f,[]>,title('sobel边
5、缘检测图像'>5PCzVD7HxAsubplot(2,2,4>,imshow(laplacian_f,[]>,title('laplacian边缘检测图像'>jLBHrnAILg运行结果:5/5<2)应用edge函数分别生成图像的Sobel、Prewitt、Roberts、LoG及Canny算子边缘检测图像,实现代码如下:xHAQX74J0Xclc,clearall,closeallf=imread('C:UsersAdministratorDesktoptungsten.tif'>。LDAYtRyKfEf=f(1:100,1:100>。sobel_f=edge(f,'sobel
6、'>。roberts_f=edge(f,'roberts'>。prewitt_f=edge(f,'prewitt'>。log_f=edge(f,'log'>。canny_f=edge(f,'canny'>。figure,subplot(2,3,1>,imshow(f>,title('原图像'>subplot(2,3,2>,imshow(roberts_f>,title('roberts边缘检测图像'>Zzz6ZB2Ltksubplot(2,3,3>,imshow(prewitt_f>,title('prewitt边缘检测图像'>dvzfvkwMI1subplot(2,3,4>,imsho
7、w(sobel_f>,title('sobel边缘检测图像'>rqyn14ZNXIsubplot(2,3,5>,imshow(log_f>,title('log边缘检测图像'>subplot(2,3,6>,imshow(canny_f>,title('canny边缘检测图像'>EmxvxOtOco运行结果:5/53.实验总结Roberts中,均反映斜角边缘;Sobel中,反映垂直边缘,反映水平边缘;Prewitt中,反映垂直边缘,反