blob分析+特征+差分
dev_update_window (‘off’)
read_image (Fins, ‘fin’ + [1:3]) *将图片转存入Fins,类似数组
get_image_size (Fins, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width[0], Height[0], ‘black’, WindowID)
set_display_font (WindowID, 14, ‘mono’, ‘true’, ‘false’)
for I := 1 to 3 by 1
select_obj (Fins, Fin, I) *select_obj ( Objects : ObjectSelected : Index : ) Index是指编号,且从 1 开始计数
dev_display (Fin)
使用二进制阈值分割图像
binary_threshold (Fin, Background, ‘max_separability’, ‘light’, UsedThreshold)
dev_set_color (‘blue’)
dev_set_draw (‘margin’)
dev_set_line_width (4)
dev_display (Background)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop ()
使用圆形元素进行闭运算
closing_circle (Background, ClosedBackground, 250)
dev_set_color (‘green’)
dev_display (ClosedBackground)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop ()
求取区域不相交的区域
difference (ClosedBackground, Background, RegionDifference) *取俩个区域不重叠部分
opening_rectangle1 (RegionDifference, FinRegion, 5, 5) *计算两个区域的差异,本算子实现是区域1-区域2,如果区域1<区域2,则结果为空
dev_display (Fin)
dev_set_color ('red')
dev_display (FinRegion)
area_center (FinRegion, FinArea, Row, Column)
if (I < 3)
disp_continue_message (WindowID, 'black', 'true')
stop ()
endif
endfor
利用closing_circle、opening_rectangle1 前后的变换使用difference 求出差集,进而提取出缺陷。