在HDevelop中
5.png
dev_update_window ('off') read_image(Image,'D:/bb/tu/5.jpg') rgb1_to_gray(Image,Image1) threshold (Image1, Region, 70, 100) hom_mat2d_identity (HomMat2D) *创建一个仿射变换矩阵 hom_mat2d_translate (HomMat2D, -140, 0, HomMat2DTranslate) *计算平移变换矩阵 *参数1:输入变换矩阵 *参数2:Row方向(y方向)的平移量 *参数3:Column方向(x方向)的平移量 *参数4:输出变换矩阵 affine_trans_region (Region, RegionAffineTrans, HomMat2DTranslate, 'nearest_neighbor') *对区域应用任意仿射2D变换 dev_open_window(0,0,521,338,'black',WindowHandle) dev_display(RegionAffineTrans)
在QtCreator中
HObject ho_Image, ho_Image1, ho_Region, ho_RegionAffineTrans;
HTuple hv_HomMat2D, hv_HomMat2DTranslate, hv_WindowHandle;
ReadImage(&ho_Image, "D:/bb/tu/5.jpg"); Rgb1ToGray(ho_Image, &ho_Image1); Threshold(ho_Image1, &ho_Region, 70, 100); HomMat2dIdentity(&hv_HomMat2D); //创建一个仿射变换矩阵 HomMat2dTranslate(hv_HomMat2D, -140, 0, &hv_HomMat2DTranslate); //计算平移变换矩阵 //参数1:输入变换矩阵 //参数2:Row方向(y方向)的平移量 //参数3:Column方向(x方向)的平移量 //参数4:输出变换矩阵 AffineTransRegion(ho_Region, &ho_RegionAffineTrans, hv_HomMat2DTranslate, "nearest_neighbor"); //对区域应用任意仿射2D变换 SetWindowAttr("background_color","black"); OpenWindow(0,0,521,338,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); if (HDevWindowStack::IsOpen()) DispObj(ho_RegionAffineTrans, HDevWindowStack::GetActive());