
在HDevelop中
對圖像平移旋轉

read_image(Image,'D:/bb/tu/4.png')
dev_open_window(0,0,250,250,'black',WindowHandle)
get_domain (Image, Domain)
area_center (Domain, Area, Row, Column)
vector_angle_to_rigid (Row, Column, 0, Row+50, Column, 3.1415/6, HomMat2D)
*計算平移和旋轉的仿射變換關系的變換矩陣
*參數1:原始點的行坐標
*參數2:原始點的列坐標
*參數3:原始點的角度
*參數4:轉換點的行坐標--y方向平移
*參數5:轉換點的列坐標--x方向平移
*參數6:轉換點的角度--旋轉角度(弧度)
*參數7:輸出轉換矩陣
affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false')
*對圖像應用任意仿射2D變換
*參數1:待變換的圖像
*參數2:變換后的圖像
*參數3:變換矩陣
*參數4:插值類型
* 值列表: 'bicubic', 'bilinear', 'constant', 'nearest_neighbor', 'weighted'
* 默認:'constant'
*參數5:決定輸出圖像的大小是否發生變化
* 值列表:'false', 'true'
dev_display(ImageAffineTrans)

對區域平移旋轉
read_image(Image,'D:/bb/tu/4.png')
rgb1_to_gray(Image,Image1)
threshold (Image1, Region, 150, 230)
area_center (Region, Area, Row, Column)
vector_angle_to_rigid (Row, Column, 0, Row+50, Column, 3.1415/6, HomMat2D)
affine_trans_region (Region, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
*對區域應用任意仿射2D變換
*參數1:待變換的區域
*參數2:已轉換的輸出區域
*參數3:變換矩陣
*參數4:插值類型
* 值列表: 'constant', 'nearest_neighbor'
* 默認: 'nearest_neighbor'
dev_open_window(0,0,250,250,'black',WindowHandle)
dev_display(RegionAffineTrans)

在QtCreator中
對圖像平移旋轉
HObject ho_Image, ho_Domain, ho_ImageAffineTrans;
HTuple hv_WindowHandle, hv_Area, hv_Row, hv_Column;
HTuple hv_HomMat2D;
ReadImage(&ho_Image, "D:/bb/tu/4.png");
SetWindowAttr("background_color","black");
OpenWindow(0,0,250,250,0,"visible","",&hv_WindowHandle);
HDevWindowStack::Push(hv_WindowHandle);
GetDomain(ho_Image, &ho_Domain);
AreaCenter(ho_Domain, &hv_Area, &hv_Row, &hv_Column);
VectorAngleToRigid(hv_Row, hv_Column, 0, hv_Row+50, hv_Column, 3.1415/6, &hv_HomMat2D);
//計算平移和旋轉的仿射變換關系的變換矩陣
//參數1:原始點的行坐標
//參數2:原始點的列坐標
//參數3:原始點的角度
//參數4:轉換點的行坐標--y方向平移
//參數5:轉換點的列坐標--x方向平移
//參數6:轉換點的角度--旋轉角度(弧度)
//參數7:輸出轉換矩陣
AffineTransImage(ho_Image, &ho_ImageAffineTrans, hv_HomMat2D, "constant", "false");
//對圖像應用任意仿射2D變換
//參數1:待變換的圖像
//參數2:變換后的圖像
//參數3:變換矩陣
//參數4:插值類型
// 值列表: 'bicubic', 'bilinear', 'constant', 'nearest_neighbor', 'weighted'
// 默認:'constant'
//參數5:決定輸出圖像的大小是否發生變化
// 值列表:'false', 'true'
if (HDevWindowStack::IsOpen())
DispObj(ho_ImageAffineTrans, HDevWindowStack::GetActive());

對區域平移旋轉
HObject ho_Image, ho_Image1, ho_Region, ho_RegionAffineTrans;
HTuple hv_Area, hv_Row, hv_Column, hv_HomMat2D;
HTuple hv_WindowHandle;
ReadImage(&ho_Image, "D:/bb/tu/4.png");
Rgb1ToGray(ho_Image, &ho_Image1);
Threshold(ho_Image1, &ho_Region, 150, 230);
AreaCenter(ho_Region, &hv_Area, &hv_Row, &hv_Column);
VectorAngleToRigid(hv_Row, hv_Column, 0, hv_Row+50, hv_Column, 3.1415/6, &hv_HomMat2D);
AffineTransRegion(ho_Region, &ho_RegionAffineTrans, hv_HomMat2D, "nearest_neighbor");
//對區域應用任意仿射2D變換
//參數1:待變換的區域
//參數2:已轉換的輸出區域
//參數3:變換矩陣
//參數4:插值類型
// 值列表: 'constant', 'nearest_neighbor'
// 默認: 'nearest_neighbor'
SetWindowAttr("background_color","black");
OpenWindow(0,0,250,250,0,"visible","",&hv_WindowHandle);
HDevWindowStack::Push(hv_WindowHandle);
if (HDevWindowStack::IsOpen())
DispObj(ho_RegionAffineTrans, HDevWindowStack::GetActive());
