一、讀取文件夾中的所有圖片
list_files ('C:/Users/fuping.liu/Desktop/檳榔有無頭/有頭', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])
endfor
二、圖像變量Region
1、預處理:
消除噪聲 | mean_image/ binomial_filter |
抑制小斑點或者細線 | median_image |
平滑 | smooth_image |
保存邊緣的平滑 | anisotropic_diffusion |
2、選擇相應區域
select_shape(regions,output,'select type',..requirements)
3、計算相應區域的面積,中心坐標:
area_center(regions,area,row,column)
4、不規則區域的轉換:
shape_trans(region,regiontrans,type)
convex hull凸包圍(由外向內包圍)
outer_circle 外圓(能夠包括對象的半徑最小的圓形)
inner_circle 內圓
rectangle1 正矩形
rectangle2 最小包圍矩形
inner_rectangle1 最大內矩形
?
5、填充區域
fill_up (region, RegionFillUp)
?
三 圖型變量XLD(eXtended Line Descriptions)
1、XLD代表亞像素級別的輪廓或者多邊形
threshold_sub_pix(inputimage, output,requirement)gen_contour_region_xld(inputRegion,output,...)edges_sub_pix(image,output,...,...)
注意:
在使用edges_sub_pix提取出來的結果,往往不是完整的圓形,需要用union來整合出完整的圓形。
2、XLD的選擇操作(select_shape_xld/selet_contours_xld):select_shape_xld(XLD:SelectedXLD:Features,Operation,Min,Max:)
select_contours_xld(Contours:SelectedContours:Feature,Min1,Max1,Min2,Max2:)
3、計算xld的面積以及中心位置:
area_center_xld(XLD:::Area,row,column,pointOrder)
4、xld的合并操作:
union_colliner_contours_xld: 合并同一直線的xldunion_cocircular_contours_xld: 合并同圓的xldunion_adjacent_contours_xld: 合并相鄰的xld
5、xld的轉換操作與region類似:
shape_trans_xld(XLD:XLDTrans:Type:)
?
6、Xld的分割操作(segment_contours_xld)
把初始xld分割成直線,直線和圓,直線和橢圓
segment_contours_xld(Contours: ContoursSplit: Mode,SmoothCont, MaxLineDist1, MaxLineDist2:)
?
7、Xld 的擬合操作(fit_***_contour_xld)? 把不完整的形狀擬合完整
fit_line_contour_xldfit_circle_contour_xldfit_ellipse_contour_xldfit_rectangle2_contour_xld
?