Halcon 常用運算元 整理(1)

JianJie
11 min readSep 20, 2020

--

影像調整

scale_image_max(Image : ImageScaleMax : : )

線性調整圖片亮度範圍為(0~255),Image: 輸入圖片(multichannel image),ImageScaleMax: 輸出圖片

equ_histo_image(Image : ImageEquHisto : : )

影像增強Histogram Equalization, Image: 輸入圖片(multichannel image),ImageEquHisto: 輸出圖片

二值化

binary_threshold(Image : Region : Method, LightDark : UsedThreshold)

圖片二值化,Image: 輸入圖片(Singlechannel),如果輸入多通道圖片,則會取圖片第一個通道(RGB Image 取 R通道圖片),Region: 二值化輸出結果,Method: 二值化方法 (‘max_separability’:Otsu threshold),LightDark: 選擇亮部或暗部,UsedThreshold: 輸出二值化閥值

threshold(Image : Region : MinGray, MaxGray : )

圖片二值化,Image: 輸入圖片,Region: 二值化輸出結果,MinGray:二值化範圍最小值,MaxGray:二值化範圍最大值

dyn_threshold(OrigImage, ThresholdImage : RegionDynThresh : Offset, LightDark : )

區域性二值化,OrigImage: 輸入圖片,ThresholdImage: 已計算完成之閥值圖,RegionDynThresh: 二值化結果,Offset: 區域性閥值,LightDark: 選擇亮部或暗部

二值化圖形態學

closing_rectangle1(Region : RegionClosing : Width, Height : )

形態學Closing,mask 為方形,Region: 輸入Region,RegionClosing: 輸出Region,Width、Height: mask寬高

closing_circle(Region : RegionClosing : Radius : )

形態學Closing,mask 為圓形,Region: 輸入Region,RegionClosing: 輸出Region,Radius: mask圓半徑

opening_rectangle1(Region : RegionOpening : Width, Height : )

形態學Opening,mask為方形,Region: 輸入Region,RegionClosing: 輸出Region,Width、Height: mask寬高

opening_circle(Region : RegionOpening : Radius : )

形態學Opening,mask為圓形,Region: 輸入Region,RegionClosing: 輸出Region,Radius: mask圓半徑

灰階形態學

gray_closing_rect(Image : ImageClosing : MaskHeight, MaskWidth : )

灰階Closing,mask 為圓形,Image: 輸入灰階圖,ImageClosing: 輸出結果圖,MaskHeight, MaskWidth: mask寬高

gray_opening_rect(Image : ImageOpening : MaskHeight, MaskWidth : )

灰階Opening,mask 為圓形,Image: 輸入灰階圖,ImageOpening: 輸出結果圖,MaskHeight, MaskWidth: mask寬高

找邊緣

boundary(Region : RegionBorder : BoundaryType : )

得到Region邊界(Region),Region: 輸入Region,RegionBorder: 輸出Region(邊界),BoundaryType: 邊界類型(‘inner’: Region內邊界,’outer’: Region外邊界,’inner_filled’: Regions內邊界,但不包含Region內的孔洞)

gen_contour_region_xld(Regions : Contours : Mode : )

得到Region邊界(xld),Region: 輸入Region,Contours: 輸出邊界xld,Mode: 邊界類型(‘border’: 外邊界,’center’: 內邊界,’border_holes’: 內邊界包含Region內的孔洞)

edges_image(Image : ImaAmp, ImaDir : Filter, Alpha, NMS, Low, High : )

得到影像的邊緣圖,Image: 輸入圖片,ImaAmp: Edge Amplitude邊緣強度,ImaDir: Edge Direction邊緣方向,Filter: 計算邊緣的方法,Alpha: Filter參數(數值越大,越平滑,NMS: Non-Maximum Suppression,
Low: 閥值下限值,High: 閥值上限值

影像相減

abs_diff_image(Image1, Image2 : ImageAbsDiff : Mult : )

兩張影像相差之絕對值,Image1, Image2: 輸入影像,由於計算輛張圖像之絕對值,因此無關順序,ImageAbsDiff: 輸出結果圖,Mult: 相減後數值相乘倍率

g’ = |(g1 — g2)| * Mult

sub_image(ImageMinuend, ImageSubtrahend : ImageSub : Mult, Add : )

影像相減,ImageMinuend: 被減的影像,ImageSubtrahend: 相減的影像,ImageSub: 相減輸出結果圖,Mult: 相減後數值相乘倍率,Add: 相減後,加上定值

g’ := (g1 — g2) * Mult + Add

建立空間

Variable := []

建立以Variable為名的空tuple

gen_empty_region( : EmptyRegion : : )

建立空Region,EmptyRegion: 空Region

gen_empty_obj( : EmptyObject : : )

建立空tuple,EmptyObject: 空tuple

Region 操作

connection(Region : ConnectedRegions : : )

將Region連通為多個單一Region (Connected Components),Region: 輸入Region,ConnectedRegions: 輸出Region

smallest_rectangle1(Regions : : : Row1, Column1, Row2, Column2)

得到Region對應最小的方框(無旋轉),Regions: 輸入Regions,Row1, Column1, Row2, Column2: 方框的角點(左上、右下)

smallest_rectangle2(Regions : : : Row, Column, Phi, Length1, Length2)

得到Region對應最小的方框(有旋轉),Regions: 輸入Regions,Row, Column: 方框中心點,Phi: 方框旋轉角度,Length1, Length2: 方框寬高

select_obj(Objects : ObjectSelected : Index : )

從tuple中選擇一個object,Objects: object tuple,ObjectSelected: 選擇的object,Index: 選擇的編號(從1開始)

select_shape(Regions : SelectedRegions : Features, Operation, Min, Max : )

篩選tuple中object,Regions: 輸入Region tuple,SelectedRegions: 篩選後Region tuple,Features: 選擇篩選的特徵(可多個),min: 篩選條件最小值,max: 篩選條件最大值

fill_up_shape(Region : RegionFillUp : Feature, Min, Max : )

填滿Region中,所選特徵範圍的部分,Region: 輸入Region,RegionFillUp: 填滿後的Region,Feature: 選擇篩選條件,Min、Max: 條件上下限值

move_region(Region : RegionMoved : Row, Column : )

移動Region位置,Region: 輸入Region,RegionMoved: 輸出Region,Row、Column: Region移動XY距離

sort_region(Regions : SortedRegions : SortMode, Order, RowOrCol : )

按順序排列Region,Region: 輸入Region,SortedRegions: 輸出Region,SortMode: 排序依據(Region位置依據),Order: 降冪or升冪,RowOrCol: 以Row或Column為優先

shape_trans(Region : RegionTrans : Type : )

Region 轉換為其他形狀(矩形、圓形、多邊形),Region: 輸入Region,RegionTrans: 輸出Region,Type: 轉換的形狀(矩形、圓形、多邊形)

Grid Region

gen_grid_region( : RegionGrid : RowSteps, ColumnSteps, Type, Width, Height : )

產生等間距網格Region,有兩種形式(Line、Point),純網格,RegionGrid: 生成的等間距Region,RowSteps: 網格高度, ColumnSteps: 網格寬度, Type: Point or Line, Width、Height: Region長寬

gen_checker_region( : RegionChecker : WidthRegion, HeightRegion, WidthPattern, HeightPattern : )

產生等間距方格Region,有填滿的區域,RegionChecker: 輸出Region,WidthRegion、HeightRegion: Region長寬, WidthPattern、HeightPattern: 方塊長寬

partition_rectangle(Region : Partitioned : Width, Height : )

將矩形分割為相等大小,Region: 輸入Region,Partitioned: 分割後的Region,Width, Height:方塊長寬(實際分割方塊大小會再調整)

gen_grid_region

gen_checker_region

expand_gray(Regions, Image, ForbiddenArea : RegionExpand : Iterations, Mode, Threshold : )

根據圖片擴展Region,Regions: 要擴展的Regions,Image: Region擴展之依據圖片,ForbiddenArea: Region不可擴展之區域,RegionExpand: 擴展後的Region,Iterations: 擴展迭代次數,Mode: ‘Image’、’Region’,’Image’:根據圖片擴展Region及消除Region重疊部分,Threshold: Region擴展的條件

對於Region重疊會有發生錯誤的情況,如下圖,當紅色Region被綠色Region分割為兩個區塊時

Regions經過expand_gray處理前

但經過expand_gray後,重疊區域難以判斷歸類為哪一個Region,因此最後重疊區域為空Region,如下圖:

Regions經過expand_gray處理後

影像操作

expand_domain_gray(InputImage : ExpandedImage : ExpansionRange : )

擴展圖片(Image Padding),InputImage: 輸入圖片,可為灰階及彩色或reduce_domain後的圖片,ExpandedImage: 擴展後圖片,ExpansionRange: 擴展半徑,以pixel為單位

--

--

JianJie
JianJie

Written by JianJie

Image Processing / Computer Vision / Deep Learning

No responses yet