当选取的特征明显且差异小时,选择两者的区别不大。
需要注意的是,NCC对遮挡和杂波以及图像中的非线性光照变化非常敏感。如果在有遮挡、杂乱或非线性照明变化的情况下发现模型,则应使用基于形状的匹配(如create_shape_model)执行搜索。
read_image(Image, 'board/board-01.png')
dev_open_window_fit_image(Image, 0, 0, -1, -1, WindowHandle)
dev_display(Image)
draw_rectangle1(WindowHandle, Row1, Column1, Row2, Column2)
gen_rectangle1(Rectangle, Row1, Column1, Row2, Column2)
*gen_rectangle1(Rectangle, 197, 186, 289, 405)
area_center(Rectangle, Area, Rowref, Columnref)
reduce_domain(Image, Rectangle, ImageReduced)
create_ncc_model(ImageReduced, 'auto', -3.14, 3.14, 'auto', 'use_polarity', ModelID)
create_shape_model(ImageReduced, 'auto', -3.14, 3.14, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID1)
for index:=2 to 20 by 1
read_image (Image0, 'board/board-' + index$'02')
find_ncc_model(Image0, ModelID, -3.14, 3.14, 0.1, 1, 0.5, 'true', 5, Row, Column, Angle, Score)
vector_angle_to_rigid(Rowref, Columnref, 0, Row, Column, Angle, HomMat2D)
affine_trans_region(Rectangle, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
dev_set_color('blue')
dev_display(RegionAffineTrans)
find_shape_model(Image0, ModelID1, -3.14, 3.14, 0.1, 1, 0.5, 'least_squares', 0, 0.9, Row3, Column3, Angle3, Score3)
vector_angle_to_rigid(Rowref, Columnref, 0, Row3, Column3, Angle3, HomMat2D)
affine_trans_region(Rectangle, RegionAffineTrans3, HomMat2D, 'nearest_neighbor')
dev_set_color('red')
dev_display(RegionAffineTrans3)
endfor