halcon-edges_image计算边缘
在HDevelop中
dev_close_window () read_image (Image, 'D:/bb/tu/1.jpg') rgb1_to_gray (Image, GrayImage) edges_image (GrayImage, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40) *计算边缘 *参数1:输入图像 *参数2:输出图像 *参数3:图像边缘方向 *参数4:边缘算子 * 'canny' * 'deriche1' * 'deriche1_int4' * 'deriche2' * 'deriche2_int4' * 'lanser1' * 'lanser2', 'mshen', 'shen', 'sobel_fast' *参数5:迭代次数,小的值导致强平滑,但是更少的细节(canny算子相反) *参数6:非最大抑制(设置为none,表示不需要使用该值) *参数7:低阈值(如果不需要阈值设置,则为负值) *参数8:高阈值(如果不需要阈值设置,则为负值),高阈值一般是低阈值的1.5-2倍 get_image_size (GrayImage, Width, Height) dev_open_window(10,10,Width, Height,'black',WindowHandle) dev_display(ImaAmp) dev_open_window(10,10,Width, Height,'black',WindowHandle1) dev_display(GrayImage)
在QtCreator中
HObject ho_Image, ho_GrayImage, ho_ImaAmp, ho_ImaDir;
HTuple hv_Width, hv_Height, hv_WindowHandle;
HTuple hv_WindowHandle1;
ReadImage(&ho_Image, "D:/bb/tu/1.jpg"); Rgb1ToGray(ho_Image, &ho_GrayImage); EdgesImage(ho_GrayImage, &ho_ImaAmp, &ho_ImaDir, "canny", 1, "nms", 20, 40); //计算边缘 //参数1:输入图像 //参数2:输出图像 //参数3:图像边缘方向 //参数4:边缘算子 // 'canny' // 'deriche1' // 'deriche1_int4' // 'deriche2' // 'deriche2_int4' // 'lanser1' // 'lanser2', 'mshen', 'shen', 'sobel_fast' //参数5:迭代次数,小的值导致强平滑,但是更少的细节(canny算子相反) //参数6:非最大抑制(设置为none,表示不需要使用该值) //参数7:低阈值(如果不需要阈值设置,则为负值) //参数8:高阈值(如果不需要阈值设置,则为负值),高阈值一般是低阈值的1.5-2倍 GetImageSize(ho_GrayImage, &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_ImaAmp, HDevWindowStack::GetActive()); SetWindowAttr("background_color","black"); OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1); HDevWindowStack::Push(hv_WindowHandle1); if (HDevWindowStack::IsOpen()) DispObj(ho_GrayImage, HDevWindowStack::GetActive());