1. 程式人生 > 其它 >halcon-erosion_rectangle1矩形區域腐蝕

halcon-erosion_rectangle1矩形區域腐蝕

1.jpg

在HDevelop中

dev_update_off()

read_image (Image, 'D:/bb/tu/1.jpg')
rgb1_to_gray(Image,Image1)
*將RGB影象轉換為灰度影象

threshold (Image1, Region, 200, 230)

erosion_rectangle1 (Region, RegionErosion, 5, 5)
*矩形區域腐蝕
*引數1:需要腐蝕的區域
*引數2:輸出區域
*引數3:結構元的寬和高


get_image_size (Image1, Width, Height)
dev_open_window(
10,10,Width, Height,'black',WindowHandle) dev_display(Region) dev_open_window(10,100,Width, Height,'black',WindowHandle1) dev_display(RegionErosion)

在QtCreator中

    HObject  ho_Image, ho_Image1, ho_Region, ho_RegionErosion;
    HTuple  hv_Width, hv_Height, hv_WindowHandle;
    HTuple  hv_WindowHandle1;
    ReadImage(&ho_Image, "D:/bb/tu/1.jpg");
    Rgb1ToGray(ho_Image, &ho_Image1);
    //將RGB影象轉換為灰度影象

    Threshold(ho_Image1, &ho_Region, 200, 230);

    ErosionRectangle1(ho_Region, &ho_RegionErosion, 5, 5);
    //矩形區域腐蝕
    //引數1:需要腐蝕的區域
    //引數2:輸出區域
    //引數3:結構元的寬和高


    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_Region, 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_RegionErosion, HDevWindowStack::GetActive());