halcon-gray_dilation_shape图像膨胀
在HDevelop中
dev_update_off() read_image (Image, 'D:/bb/tu/1.jpg') rgb1_to_gray(Image,Image1) *将RGB图像转换为灰度图像 gray_dilation_shape (Image1, ImageMax, 5, 5, 'octagon') *图像膨胀-->效果:增加亮部,减少暗 *参数1:灰度值图像 *参数2:输出图像 *参数3和参数4:结构元的宽和高部 *参数5:结构元形状 * 'octagon' 八角形 * 'rectangle' 矩形 * 'rhombus' 棱形 get_image_size (Image1, Width, Height) dev_open_window(10,10,Width, Height,'black',WindowHandle) dev_display(Image1) dev_open_window(10,100,Width, Height,'black',WindowHandle1) dev_display(ImageMax)
在QtCreator中
HObject ho_Image, ho_Image1, ho_ImageMax;
HTuple hv_Width, hv_Height, hv_WindowHandle;
HTuple hv_WindowHandle1;
ReadImage(&ho_Image, "D:/bb/tu/1.jpg"); Rgb1ToGray(ho_Image, &ho_Image1); //将RGB图像转换为灰度图像 GrayDilationShape(ho_Image1, &ho_ImageMax, 5, 5, "octagon"); //图像膨胀-->效果:增加亮部,减少暗 //参数1:灰度值图像 //参数2:输出图像 //参数3和参数4:结构元的宽和高部 //参数5:结构元形状 // 'octagon' 八角形 // 'rectangle' 矩形 // 'rhombus' 棱形 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_Image1, 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_ImageMax, HDevWindowStack::GetActive());