在HDevelop中
表盘.jpg
dev_update_off() read_image(Image,'D:/bb/tu/表盘.jpg') get_image_size (Image, Width, Height) dev_open_window(0,0,Width,Height,'black',WindowHandle) disp_obj (Image, WindowHandle) ******获取表盘中心坐标、获取表盘图像******** draw_circle (WindowHandle, Row, Column, Radius) gen_circle (Circle, Row, Column, Radius) reduce_domain (Image, Circle, ImageReduced) ****************************************** polar_trans_image_ext (ImageReduced, PolarTransImage, Row, Column, 0, 6.28319, 0, Radius, 2*3.1415*Radius, Radius, 'nearest_neighbor') *将图像中的圆弧变换为极坐标-->圆环拉成直线 *参数1:输入图像 *参数2:输出图像 *参数3:圆弧中心的行坐标-y *参数4:圆弧中心的列坐标-x *参数5:起始弧度,默认值:0.0;【0弧度对应表盘的3点,顺时针为正】 *参数6:结束弧度 *参数7:极坐标开始的极长,一般是0 *参数8:极坐标结束的极长,一般是圆半径r *参数9:图片宽,一般2πr *参数10:图片高【r】 *参数11:插值,值列表:'bilinear', 'nearest_neighbor' dev_open_window(0,0,2*3.1415*Radius,Radius,'black',WindowHandle1) disp_obj (PolarTransImage, WindowHandle1)
在QtCreator中
HObject ho_Image, ho_Circle, ho_ImageReduced;
HObject ho_PolarTransImage;
HTuple hv_Width, hv_Height, hv_WindowHandle;
HTuple hv_Row, hv_Column, hv_Radius, hv_WindowHandle1;
ReadImage(&ho_Image, //'D:/bb/tu/表盘.jpg' "D:/bb/tu/\350\241\250\347\233\230.jpg"); GetImageSize(ho_Image, &hv_Width, &hv_Height); SetWindowAttr("background_color","black"); OpenWindow(0,0,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); DispObj(ho_Image, hv_WindowHandle); //*****获取表盘中心坐标、获取表盘图像******** DrawCircle(hv_WindowHandle, &hv_Row, &hv_Column, &hv_Radius); GenCircle(&ho_Circle, hv_Row, hv_Column, hv_Radius); ReduceDomain(ho_Image, ho_Circle, &ho_ImageReduced); //***************************************** PolarTransImageExt(ho_ImageReduced, &ho_PolarTransImage, hv_Row, hv_Column, 0, 6.28319, 0, hv_Radius, (2*3.1415)*hv_Radius, hv_Radius, "nearest_neighbor"); //将图像中的圆弧变换为极坐标-->圆环拉成直线 //参数1:输入图像 //参数2:输出图像 //参数3:圆弧中心的行坐标-y //参数4:圆弧中心的列坐标-x //参数5:起始弧度,默认值:0.0;【0弧度对应表盘的3点,顺时针为正】 //参数6:结束弧度 //参数7:极坐标开始的极长,一般是0 //参数8:极坐标结束的极长,一般是圆半径r //参数9:图片宽,一般2πr //参数10:图片高【r】 //参数11:插值,值列表:'bilinear', 'nearest_neighbor' SetWindowAttr("background_color","black"); OpenWindow(0,0,(2*3.1415)*hv_Radius,hv_Radius,0,"visible","",&hv_WindowHandle1); HDevWindowStack::Push(hv_WindowHandle1); DispObj(ho_PolarTransImage, hv_WindowHandle1);