仿射affine--案例

read_image (Image, 'D:/Project/PC/vision_2020/视库/样图/线路.bmp')
dev_get_window (WindowHandle)
threshold (Image, Region, 0, 200)
opening_circle (Region, Region, 1.5)
connection (Region, ConnectedRegions)
select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)
*得到变换的中心点
area_center (SelectedRegions, Area, Row, Column)
dev_set_draw ('margin')

*hom_mat2d_translate中的两个参数的意思是:Tx和Ty分别代表Row方向和Column方向的平移量
dev_display (Image)
disp_cross (WindowHandle, Row, Column, 10, 40)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity,30, 150, HomMat2DTranslate)

*hom_mat2d_rotate中的三个参数的意思是:旋转角度(逆时针为正,弧度制),旋转中心的row和column值
dev_display (Image)
disp_cross (WindowHandle, Row, Column, 10, 40)
hom_mat2d_rotate (HomMat2DIdentity, rad(20), Row, Column, HomMat2DRotate)
affine_trans_region (Region, RegionAffineTrans, HomMat2DRotate, 'nearest_neighbor')

*hom_mat2d_scale中的四个参数的意思是:Sx和Sy分别代表Row方向和Column方向的缩放系数,缩放中心的row和column值
dev_display (Image)
disp_cross (WindowHandle, Row, Column, 10, 40)
hom_mat2d_scale (HomMat2DIdentity, 2.0, 1.05, Row, Column, HomMat2DScale)
affine_trans_region (Region, RegionAffineTrans, HomMat2DScale, 'nearest_neighbor')

猜你喜欢

转载自www.cnblogs.com/dingyd/p/12941694.html