halcon學習筆記——(11)Image,region,xld初步


一 讀取的3種方式:

read_image( image,'filename')       //image 是輸出對象,后面是輸入文件的路徑和名稱

讀取多圖:
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(輸入文件目錄地址,選取的要求(files指定選取文件格式,recursive遞歸,深入所有,derectories選取文件夾,follow_links,max_depth 5...),輸出的被選擇的文件列表)

選擇符合規則的tuple,其中\\.是轉義符,等價於'-->'
tuple_regexp_select(文件名字,['\\.(bmp|tif)$','ignore_case忽略大小寫'],輸出)
fabric文件路徑
 
二 圖像變量Region
預處理:

消除噪聲 mean_image/ binomial_filter
抑制小斑點或者細線 median_image
平滑 smooth_image
保存邊緣的平滑 anisotropic_diffusion

 

變量Region:
Region 為某些附和要求性質的像素的子集,或者說一些被選擇的圖塊區域s,region大小不受圖像限制,有fill和margin兩種表達方式,類似於游程編碼,可用於壓縮,eg:用a2b3c4代表aabbbcccc

region操作:
選擇相應區域

select_shape(regions,output,'select type',..requirements)

計算相應區域的面積,中心坐標:

area_center(regions,area,row,column)

不規則區域的轉換:

shape_trans(region,regiontrans,type)

image

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

image

Xld 的擬合操作(fit_***_contour_xld)  把不完整的形狀擬合完整

fit_line_contour_xld
 
fit_circle_contour_xld
 
fit_ellipse_contour_xld
 
fit_rectangle2_contour_xld

總結:

圖像和視頻,文件的讀取

Region和XLD的初步介紹

注意:

在使用edges_sub_pix提取出來的結果,往往不是完整的圓形,需要用union來整合出完整的圓形。

 

原文來自: Burning_foot的博客


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM