遍历文件夹与文件选择与XLD(halcon)

来源:互联网 发布:科摩多手机安全软件 编辑:程序博客网 时间:2024/06/05 11:21

读取多图: 
1,申明一个数组,分别保存路径

ImagePath:=[] ImagePath[0]:='D:/1.bmp' ImagePath[1]:='D:/2.bmp' ImagePath[2]:='D:/3.bmp' for i:=0 to 2 by 1 read_image(Image,ImagePath[i]) endfor

2,for 循环  
  

for i:=1 to 3 by 1 read_image(Image,'D:/’+'i'+'.bmp') endfor
 
3,遍历法
list_files( : : Directory, Options : Files)
 
文件格式筛选tuple_regexp_select( : : Data, Expression : Selection) 

 代码部分:
list_files ('C:/Users/Public/Pictures/Sample Pictures', 'files', Files)
tuple_regexp_select (Files, ['\\.(bmp|jpg)$','ignore_case'], ImageFiles)
* 依次读取图片
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles[Index])
    wait_seconds (1)
    binomial_filter (Image, ImageBinomial, 5, 5)
    wait_seconds (1)
endfor
这个可以用在读取一个文件夹里面一堆图片的情况下,之前还写了循环去读取,没想到halcon已经集成了相应算子。  

二 不规则区域的转换:

shape_trans(region,regiontrans,type)
图片

convex hull凸包围(由外向内包围)

outer_circle 外圆(能够包括对象的半径最小的圆形)

inner_circle 内圆

rectangle1 正矩形

rectangle2 最小包围矩形

inner_rectangle1 最大内矩形 

三 图型变量XLD(eXtended Line Descriptions)

XLD代表亚像素级别的轮廓或者多边形

threshold_sub_pix(inputimage, output,requirement) gen_contour_region_xld(inputRegion,output,...)

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:)

计算xld的面积以及中心位置:

area_center_xld(XLD:::Area,row,column,pointOrder)

xld的合并操作:

union_colliner_contours_xld: 合并同一直线的xld union_cocircular_contours_xld: 合并同圆的xld union_adjacent_contours_xld: 合并相邻的xld

xld的转换操作与region类似:

shape_trans_xld(XLD:XLDTrans:Type:)

有上面几个类型

Xld的分割操作(segment_contours_xld)

把初始xld分割成直线,直线和圆,直线和椭圆

segment_contours_xld(Contours: ContoursSplit: Mode,SmoothCont, MaxLineDist1, MaxLineDist2:)

Xld 的拟合操作(fit_***_contour_xld)  把不完整的形状拟合完整

fit_line_contour_xld 
fit_circle_contour_xld 
fit_ellipse_contour_xld 
fit_rectangle2_contour_xld 
 


0 0
原创粉丝点击