要求:拍摄树叶照片,正反两张,提取叶脉,测量叶脉的分支,以及分支的倾斜角。
霍夫变换以及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(:)))); %