hom_mat2d_identity(HomMat2D) //定义一个矩阵
1.Translation平移
hom_mat2d_translate( : : HomMat2D, Tx, Ty : HomMat2DTranslate)
HomMat2D, Tx, Ty输入;HomMat2DTranslate输出
例子:
affine_trans_region(Region : RegionAffineTrans : HomMat2D, Interpolate : )
Region,HomMat2D输入;RegionAffineTrans输出;Interpolate一般为最小临值法’nearest_neighbor’
set_system('clip_region','false') //图片以外的region不要剪裁
2.rotate旋转
hom_mat2d_rotate( : : HomMat2D, Phi, Px, Py : HomMat2DRotate)
HomMat2D输入,Phi角度,Px, Py绕哪一个点进行旋转,HomMat2DRotate输出
3.local
不加local就是一图像的原始坐标进行变换;加了local则是建立了一个新的坐标系进行变换。
例子:
*local
hom_mat2d_identity(HomMat2DIdentity4)
hom_mat2d_translate(HomMat2DIdentity4, 0, 1600, HomMat2DTranslate2)
affine_trans_region(Roi_0,RegionAffineTrans4, HomMat2DTranslate2, 'nearest_neighbor')
hom_mat2d_rotate_local(HomMat2DTranslate2,rad(90),HomMat2DRotate2) //旋转的坐标系为平移后的远点坐标系
affine_trans_region(Roi_0,RegionAffineTrans5, HomMat2DRotate2, 'nearest_neighbor')
4.vector_angle_to_rigid将上述的旋转加平移合二为一
vector_angle_to_rigid( : : Row1, Column1, Angle1, Row2, Column2, Angle2 : HomMat2D)
其中,Row1, Column1, Angle1输入,前者(原始)的起始坐标以及角度方向
Row2, Column2, Angle2输入,移动后的起始点坐标以及角度方向
HomMat2D输出矩阵
affine_trans_point_2d( : : HomMat2D, Px, Py : Qx, Qy)
HomMat2D输入
Px, Py输入
Qx, Qy输出
例子:
*vector_angle_to_rigid
gen_region_line(Roi_0,168.25,215.125,161.219,555.75)
angle_lx(168.25,215.125,161.219,555.75,phi1)
gen_circle(Roi_0,255.203,335.438,52)
gen_region_line(Rio_2,607.626,776.27,323.202,1057.94)
angle_lx(607.626,776.27,323.202,1057.94,phi2)
vector_angle_to_rigid(168.25,215.125,phi1,607.626,776.27,phi2,HomMat2D) //求出移动变换之后的矩阵
affine_trans_point_2d(HomMat2D,255.203,335.438,row,col) //得出圆心坐标
gen_circle(Circle,row,col,52)
affine_trans_pixel( : : HomMat2D, Row, Col : RowTrans, ColTrans) 不太用
affine_trans_point_2d (HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)
RowTrans := RowTmp-0.5
ColTrans := ColTmp-0.5