halcon |
您所在的位置:网站首页 › halcon中scale_image › halcon |
ReadImage(&ho_Image, "D:/bb/tu/8.png"); GetImageSize(ho_Image, &hv_Width, &hv_Height); Decompose3(ho_Image, &ho_Red, &ho_Green, &ho_Blue); //将RGB三通道数据转化为HSV色彩空间的三通道图像数据 //HSV:看 TransFromRgb(ho_Red, ho_Green, ho_Blue, &ho_Hue, &ho_Saturation, &ho_Intensity, "hsv"); //对HSV图像中的饱和度通道进行阈值操作 Threshold(ho_Saturation, &ho_HighSaturation, 200, 255); //获取上述阈值操作后区域中的色调通道图像数据 ReduceDomain(ho_Hue, ho_HighSaturation, &ho_HueHighSaturation); //对上述色调通道图像数据进行阈值处理 Threshold(ho_HueHighSaturation, &ho_Yellow, 20, 30); //寻找连通域 Connection(ho_Yellow, &ho_ConnectedRegions); //保留ConnectedRegions里的最大的区域 SelectShapeStd(ho_ConnectedRegions, &ho_SelectedRegions, "max_area", 0); //对SelectedRegions进行闭运算操作 ClosingCircle(ho_SelectedRegions, &ho_Yellow, 3.5); //将Yellow区域里的图像剪切出来 ReduceDomain(ho_Image, ho_Yellow, &ho_ImageReduced); SetWindowAttr("background_color","black"); OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); if (HDevWindowStack::IsOpen()) DispObj(ho_ImageReduced, HDevWindowStack::GetActive()); |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |