在HDevelop中
4.jpg
dev_open_window(10,10,307,221,'black',WindowHandle) read_image (Image, 'D:/bb/tu/4.jpg') rgb1_to_gray(Image,Image1) *將RGB圖像轉換為灰度圖像 threshold (Image1, Region, 60, 100) set_color(WindowHandle,'blue') boundary (Region, RegionBorder, 'outer') *提取邊界 *參數1:要計算其邊界的區域 *參數2:保存邊界區域 *參數3:邊界類型 * 'inner' 內邊界--默認:輪廓位於原始區域內 * 'inner_filled' 內部孔的邊界: * 'outer' 外邊界:輪廓位於原始區域外一個像素 dev_display (RegionBorder)
參數3是'outer'
參數3是'inner_filled'
在QtCreator中
HObject ho_Image, ho_Image1, ho_Region, ho_RegionBorder;
HTuple hv_WindowHandle;
SetWindowAttr("background_color","black"); OpenWindow(10,10,307,221,0,"visible","",&hv_WindowHandle); ReadImage(&ho_Image, "D:/bb/tu/4.jpg"); Rgb1ToGray(ho_Image, &ho_Image1); //將RGB圖像轉換為灰度圖像 Threshold(ho_Image1, &ho_Region, 60, 100); SetColor(hv_WindowHandle, "blue"); Boundary(ho_Region, &ho_RegionBorder, "outer"); //提取邊界 //參數1:要計算其邊界的區域 //參數2:保存邊界區域 //參數3:邊界類型 // 'inner' 內邊界--默認:輪廓位於原始區域內 // 'inner_filled' 內部孔的邊界: // 'outer' 外邊界:輪廓位於原始區域外一個像素 SetPart(hv_WindowHandle,0, 0, 221, 307); //修改圖像在激活窗口的顯示區域 DispObj(ho_RegionBorder, hv_WindowHandle);