www.gusucode.com > images 案例代码 matlab源码程序 > images/DetectEdgesInImagesExample.m

    %% Detect Edges in Images
% This example shows how to detect edges in an image using both the Canny
% edge detector and the Sobel edge detector.
%%
% Read image and display it.

% Copyright 2015 The MathWorks, Inc.

I = imread('coins.png');
imshow(I)
%%
% Apply both the Sobel and Canny edge detectors to the image and display
% them for comparison.
BW1 = edge(I,'sobel');
BW2 = edge(I,'canny');
figure;
imshowpair(BW1,BW2,'montage')
title('Sobel Filter                                   Canny Filter');