方法一:
clear all; clc; close all;
Img = imread('test.jpg');
figure;
subplot(2, 2, 1); imshow(Img); title('original image');
I = rgb2gray(Img);
subplot(2, 2, 2); imshow(I); title('gray image');
bw = im2bw(I, graythresh(I));
bw = edge(bw, 'canny');
subplot(2, 2, 3); imshow(bw); title('ca