在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());