資源簡介
基于matlab的 圖像特征分類識別 圖像處理 分割 樹葉圖像特征提取

代碼片段和文件信息
clear
close?all
colors=[‘r‘‘k‘‘g‘];
%%%%%%%%%%%%%%提取待識別圖像各區域特征
image1=imread(‘test.tif‘);
%figure?imshow(mat2gray(image1));
tt=graythresh(image1);%用OTSU法計算全局閾值
image2=im2bw(image1tt);
%figure?imshow(image2);
image3=~image2;%反轉
%figure?imshow(image3);
SE?=?strel(‘disk‘5);%選取形態學結構元素
i2=?imclose(image3SE);%閉運算
i2=?imfill(i2‘hole‘);%填洞
%figure?imshow(i2);
[BL]=bwboundaries(i2‘noholes‘);%確定區域邊界
STATS1=regionprops(L‘all‘);%提取區域屬性
[Lnum]?=?bwlabel(i2);?%標記
figureimshow(mat2gray(image1));
hold?on
for?n=1:3
????%%%%%%%%%%%%%%%%%%%%%%%?提取樣本特征
??name=strcat(num2str(n)‘.tif‘);
??im1=imread(name);???
tt=graythresh(im1);
im2=im2bw(im1tt);
%figure?imshow(im2);?
im3=~im2;
%figure?imshow(im3);
SE?=?strel(‘disk‘5);
im=?imclose(im3SE);
im=?imfill(im‘hole‘);
%figure(n)imshow(im);
STATS=regionprops(im‘all‘);%提取樣本屬性
b1=STATS.Extent;??%樣本圖像屬性:像素比例和偏心率
d1=STATS.Eccentricity;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for?t=1:num
???b2=STATS1(t).Extent;
???d2=STATS1(t).Eccentricity?;
???c(t)=sqrt((b1-b2)^2+(d1-d2)^2);
if?c(t)<0.1??????%分類閾值
?rectangle(‘Position‘[STATS1(t).BoundingBox]‘EdgeColor‘colors(n));%顯示結果
end
end
?%figure(n)plot(1:16c‘*‘);ylabel(‘c(t)‘);xlabel(‘區域編號t‘);
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????456772??2006-12-29?18:54??圖像特征分類識別程序\1.tif
?????文件??????98456??2006-12-29?19:11??圖像特征分類識別程序\2.tif
?????文件????1156394??2006-12-30?16:11??圖像特征分類識別程序\3.tif
?????文件???????1350??2012-12-23?11:46??圖像特征分類識別程序\main_test.m
?????文件????5617342??2012-12-05?20:26??圖像特征分類識別程序\test.tif
?????目錄??????????0??2012-12-29?22:26??圖像特征分類識別程序
-----------?---------??----------?-----??----
??????????????7330314????????????????????6
評論
共有 條評論