在HDevelop中
read_image (Image, 'D:/bb/tu/5.jpg') rgb1_to_gray(Image,Image1) threshold (Image1, Region,[75] , [90]) smallest_circle (Region, Row, Column, Radius) *獲取區域最小外接圓數據 *參數1:輸入給定區域 *參數2:輸出中心行坐標-y坐標 *參數3:輸出中心列坐標-x坐標 *參數4:輸出外接圓半徑 gen_circle (Circle, Row, Column, Radius) *創建一個圓區域 get_image_size (Image1, Width, Height) dev_open_window(10,10,Width, Height,'black',WindowHandle) dev_display(Region) dev_open_window(10,100,Width, Height,'black',WindowHandle1) dev_display(Circle)
在QtCreator中
HObject ho_Image, ho_Image1, ho_Region, ho_Circle;
HTuple hv_Row, hv_Column, hv_Radius, hv_Width;
HTuple hv_Height, hv_WindowHandle, hv_WindowHandle1;
ReadImage(&ho_Image, "D:/bb/tu/5.jpg"); Rgb1ToGray(ho_Image, &ho_Image1); Threshold(ho_Image1, &ho_Region, 75, 90); SmallestCircle(ho_Region, &hv_Row, &hv_Column, &hv_Radius); //獲取區域最小外接圓數據 //參數1:輸入給定區域 //參數2:輸出中心行坐標-y坐標 //參數3:輸出中心列坐標-x坐標 //參數4:輸出外接圓半徑 GenCircle(&ho_Circle, hv_Row, hv_Column, hv_Radius); //創建一個圓區域 GetImageSize(ho_Image1, &hv_Width, &hv_Height); SetWindowAttr("background_color","black"); OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); if (HDevWindowStack::IsOpen()) DispObj(ho_Region, HDevWindowStack::GetActive()); SetWindowAttr("background_color","black"); OpenWindow(10,100,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1); HDevWindowStack::Push(hv_WindowHandle1); if (HDevWindowStack::IsOpen()) DispObj(ho_Circle, HDevWindowStack::GetActive());