高斯模糊擬合激光條法:
dev_close_window ()
* 設置顏色
dev_set_color ('green')
* 讀取圖像
read_image (Image, 'images3/1')
* 獲得圖像尺寸
get_image_size (Image, Width, Height)
* 開啟窗口
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
* 均值濾波為了將光條處理的更加平滑
mean_image (Image, Image, 3, 3)
* 灰度化
rgb1_to_gray (Image, GrayImage)
* 二值化
threshold (GrayImage, Regions, 34, 255)
* 提取骨架
skeleton (Regions, Skeleton)
* 提取骨架點
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
difference (Skeleton, JuncPoints, RegionDifference)
* 計算聯通域
connection (RegionDifference, ConnectedRegions)
* 通過點計算線的區域
split_skeleton_region (ConnectedRegions, RegionLines, 9)
* 計算數量
count_obj (RegionLines, Number)
* 生成空白對象以備使用,存儲最終結果
gen_empty_obj (PrintedLines)
* 循環遍歷來過濾一些短的線
for Index:=1 to Number by 1
* 按照索引取出對象
select_obj (RegionLines, LineRegion, Index)
* 將區域轉換為線條
gen_contour_region_xld (LineRegion, Line, 'center')
* 計算長度
length_xld (Line, Length)
if (Length > 100)
* 保存結果
concat_obj (PrintedLines, Line, PrintedLines)
endif
endfor
* 展示結果
dev_clear_window ()
dev_display (PrintedLines)
高斯模糊擬合激光條法:
dev_close_window ()
* 設置顏色
dev_set_color ('green')
* 讀取圖像
read_image (Image, 'images3/1')
* 獲得圖像尺寸
get_image_size (Image, Width, Height)
* 開啟窗口
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
calculate_lines_gauss_parameters (8, [12,5], Sigma, Low, High)
lines_gauss (Image, Lines, Sigma, Low, High, 'light', 'true', 'parabolic', 'true')
select_contours_xld (Lines, RelLines, 'length', 5.0, 999, 0, 0)
* 計算數量
count_obj (RelLines, Number)
* 生成空白對象以備使用,存儲最終結果
gen_empty_obj (PrintedLines)
* 循環遍歷來過濾一些短的線
for Index:=1 to Number by 1
* 按照索引取出對象
select_obj (RelLines, Line, Index)
* 計算長度
length_xld (Line, Length)
if (Length > 100)
* 保存結果
concat_obj (PrintedLines, Line, PrintedLines)
endif
endfor
* 展示結果
dev_clear_window ()
dev_display (PrintedLines)
