

在HDevelop中
dev_close_window ()
read_image (Image, 'D:/bb/tu/4.jpg')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 90, 95)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 12800, 12980)
gen_contour_region_xld (SelectedRegions, Contours, 'border')
*根據區域創建XLD輪廓(contour)
*參數1:輸入區域
*參數2:輸出輪廓
*參數3:輪廓生成模式
* 'border' 邊界像素的外邊界作為輪廓點
* 'border_holes' 除了輸入區域的外邊界,還可以得到所有孔的輪廓
* 'center' 邊界像素的中心用作輪廓點
get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle3)
dev_display(Contours)

在QtCreator中
HObject ho_Image, ho_GrayImage, ho_Region, ho_ConnectedRegions;
HObject ho_SelectedRegions, ho_Contours;
HTuple hv_Width, hv_Height, hv_WindowHandle3;
ReadImage(&ho_Image, "D:/bb/tu/4.jpg");
Rgb1ToGray(ho_Image, &ho_GrayImage);
Threshold(ho_GrayImage, &ho_Region, 90, 95);
Connection(ho_Region, &ho_ConnectedRegions);
SelectShape(ho_ConnectedRegions, &ho_SelectedRegions, "area", "and", 12800, 12980);
GenContourRegionXld(ho_SelectedRegions, &ho_Contours, "border");
//根據區域創建XLD輪廓(contour)
//參數1:輸入區域
//參數2:輸出輪廓
//參數3:輪廓生成模式
// 'border' 邊界像素的外邊界作為輪廓點
// 'border_holes' 除了輸入區域的外邊界,還可以得到所有孔的輪廓
// 'center' 邊界像素的中心用作輪廓點
GetImageSize(ho_GrayImage, &hv_Width, &hv_Height);
SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle3);
HDevWindowStack::Push(hv_WindowHandle3);
if (HDevWindowStack::IsOpen())
DispObj(ho_Contours, HDevWindowStack::GetActive());
