使用Sobel进行边缘检测: >> i=imread('circuit.tif'); >> bw1=edge(i,'roberts'); >> subplot(1,2,1);imshow(i); >> subplot(1,2,2);imshow(bw1); >> clear;
>> image=imread('circuit.tif'); >> i0=edge(image,'sobel'); >> i1=edge(image,'sobel',0.06); >> i2=edge(image,'sobel',0.04); >> i3=edge(image,'sobel',0.02); >> subplot(2,3,1);imshow(image); >> subplot(2,3,2);imshow(i0); >> subplot(2,3,3);imshow(i1); >> subplot(2,3,4);imshow(i2); >> subplot(2,3,5);imshow(i3);
使用Prewitt算子进行边缘检测: >> i=imread('rice.png'); >> subplot(2,2,1);imshow(i); >> bw3=edge(i,'prewitt');
>> subplot(2,2,2);imshow(bw3); >> [bw3,th3]=edge(i,'prewitt');
>> bw3=edge(i,'prewitt',0.05,'horizontal'); >> subplot(2,2,3);imshow(bw3);
>> bw3=edge(i,'prewitt',0.05,'vertical'); >> subplot(2,2,4);imshow(bw3);
使用Log算子进行边缘检测: >> i=imread('circuit.tif'); >> [bw1,th]=edge(i,'log'); >> subplot(2,3,1);imshow(i); >> subplot(2,3,2);imshow(bw1); >> bw2=edge(i,'log',0.0056); >> subplot(2,3,3);imshow(bw2); >> h=fspecial('gaussian',5);
>> [bw3,th3]=edge(i,'zerocross',[],h); >> subplot(2,3,4);imshow(bw3); >> bw4=edge(i,'zerocross',0.025,h); >> subplot(2,3,5);imshow(bw4);
使用Canny算子进行边缘检测: >> i=imread('circuit.tif'); >> subplot(1,3,1);imshow(i); >> [bw,th]=edge(i,'canny'); >> subplot(1,3,2);imshow(bw);
>> [bw1,th1]=edge(i,'canny',[0.2,0.6]); >> subplot(1,3,3);imshow(bw1);