資源簡介
例子是用來提取葉片形狀參數(shù)的,如果感興趣可以拿去參考,修改。。。
代碼片段和文件信息
%計算葉片特征
for?n=1:207
k=sprintf(‘%d.jpg‘n);
i=imread(k);
?hd=rgb2gray(i);
?sh=im2double(hd);
bw=im2bw(sh0.8);
bw2=imcomplement(bw);
bw3=imfill(bw2‘holes‘);
BW=bwareaopen(bw330);
[labelednumobjects]=bwlabel(BW8);
stats=regionprops(labeled‘a(chǎn)ll‘);
data_Axis=[stats.BoundingBox];%最小包圍盒
MajorAxis=data_Axis(13);%長軸長度
MinorAxis=data_Axis(14);%短軸長度
ar=[stats.Area];%計算面積
評論
共有 條評論