|
二值化模板图像匹配
- dev_update_off()
- dev_set_draw('margin')
- read_image (Image, 'E:/视频讲解/图库/4Cam0_00.PNG')
- get_image_size(Image, Width, Height)
- * 加载模型
- read_region(ModelEdges, 'regionMatchingModel.hobj')
- * 提取纹理特征
- * inspect_shape_model(Image, ModelImages, ModelRegions, 1, 10)
- texture_laws(Image, ImageEL, 'el', 5, 5)
- threshold(ImageEL,Region,5,255)
- texture_laws (Image, ImageLE, 'le', 5, 5)
- threshold(ImageLE,Region1,5,255)
- union2(Region, Region1, RegionUnion)
- * blob分析
- connection(RegionUnion, ConnectedRegions)
- select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 150, 9999999)
- union1(SelectedRegions, RegionUnion1)
- * 二值化配准
- zbest_Area:=0
- zbest_Rx:=0
- zbest_Cx:=0
- zbest_Cita:=0
- gen_empty_obj(zbest_Region)
- region_features(RegionUnion1, 'area', Value)
- if(Value>0)
- smallest_rectangle1(RegionUnion1, Row1, Column1, Row2, Column2)
- smallest_rectangle1(ModelEdges, Row11, Column11, Row21, Column21)
- move_region(ModelEdges, InitPos, Row1-Row11, Column1-Column11)
-
- for cita:= -1 to 1 by 0.5
- vector_angle_to_rigid(Height/2,Width/2,0,Height/2,Width/2,rad(cita),HomMat2D)
- affine_trans_region(RegionUnion1, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
- for Rx:=0 to 30 by 2
- for Cx:=0 to 30 by 2
- move_region(InitPos, RegionMoved, Rx, Cx)
- intersection(RegionMoved, RegionAffineTrans, RegionIntersection)
- region_features(RegionIntersection, 'area', Value1)
- if(Value1>zbest_Area)
- zbest_Area:=Value1
- zbest_Rx:=Rx
- zbest_Cx:=Cx
- zbest_Cita:=cita
- union1(RegionMoved, zbest_Region)
- endif
- endfor
- endfor
- endfor
-
-
- endif
复制代码
|
|