树叶叶脉的提取及描述

来源:互联网 发布:高仿古驰男鞋淘宝店 编辑:程序博客网 时间:2024/04/27 23:06

要求:拍摄树叶照片,正反两张,提取叶脉,测量叶脉的分支,以及分支的倾斜角。

霍夫变换以及canny算子理论百度。。。。


程序:

clc,close    BW=imread('leaf.jpg');      BW=rgb2gray(BW);    thresh=[0.13,0.3]; %阈值设置根据图像自定义范围 sigma=1;%定义高斯参数,1-3   f = edge(double(BW),'canny',thresh,sigma);    figure(1),imshow(f,[]);    title('canny 边缘检测');%canny边缘算子    [H, theta, rho]= hough(f,'RhoResolution', 0.5,'ThetaResolution',0.75);    %imshow(theta,rho,H,[],'notruesize'),axis on,axis normal%霍夫变换空间图%xlabel('\theta'),ylabel('rho');        peak=houghpeaks(H,8,'threshold', ceil(0.3*max(H(:))));  %求出显示霍夫变换矩阵中的8个极值点hold on        lines=houghlines(f,theta,rho,peak);% 找原图中的线    figure,imshow(f,[]),title('Hough Transform Detect Result'),hold onmax_len=0;for k=1:length(lines)        xy=[lines(k).point1;lines(k).point2];     xielv(k)=(lines(k).point2(1)-lines(k).point1(1))/(lines(k).point2(2)-lines(k).point1(2)+0.0001);%求直线斜率      plot(xy(:,1),xy(:,2),'LineWidth',4,'Color',[.6 .6 .6]); %绘制各条直线 end  ang = atan(xielv)*180/pi%求各条直线角度 

原始图像:   

         

canny算子边缘检测结果

霍夫变换取直线结果:


霍夫变换直线结果还是不明显,对图片识别度不高。


0 0
原创粉丝点击