edge函数 MATLAB,求助,为何edge函数无法正常运行?代码及图片如下

clcclear allf_rgb=imread('leaf/RGB/2. Salix atrocinerea/iPAD2_C02_EX08.jpg');subplot(221)imshow(f_rgb);title '叶子彩色图'f_gray=rgb2gray(f_rgb);f_med=medfilt2(f_gray,[9,9]);BW1=edge(f_med,'canny');subplot(222)imshow(f_gray); title '叶子灰度图'subplot(223)imshow(BW1); title '叶子边缘'

代码如下:

特别提醒:最后的边缘提取(效果见第二张图),使用了一个函数boundarymask,这个函数是matlab R2016a版本新引入的函数,低版本中没有。如果你使用低版本的matlab,EDGE1这部分代码可以使用edge替代(即直接使用edge对BW1提取边缘,sobel,canny都可以),但效果可能不如boundarymask。

clc; clear; close all;

f_rgb=imread('1.jpg');
figure;
subplot(221),imshow(f_rgb),title('叶子彩色图');

f_gray=rgb2gray(f_rgb);
subplot(222),imshow(f_gray),title('叶子灰度图');

BW1 = ~im2bw(f_gray, graythresh(f_gray));
BW1 = imfill(BW1, 'holes');
subplot(223),imshow(BW1),title('分割');

EDGE1 = boundarymask(BW1);
subplot(224),imshow(EDGE1),title('叶子边缘');

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答