halcon-complement區域的反選


 

 

在HDevelop中

read_image (Image, 'D:/bb/tu/4.jpg')
rgb1_to_gray(Image,Image1)
*將RGB圖像轉換為灰度圖像

threshold (Image1, Region,[80] , [90])


complement (Region, RegionComplement)
*區域的反選--獲取參數1之外的區域



get_image_size (Image1, Width, Height)

dev_open_window(10,100,Width, Height,'black',WindowHandle)
dev_display(Region)
dev_open_window(10,100,Width, Height,'black',WindowHandle1)
dev_display(RegionComplement)

 

 


在Qt Creator中

    HObject  ho_Image, ho_Image1, ho_Region, ho_RegionComplement;
    HTuple  hv_Width, hv_Height, hv_WindowHandle;
    HTuple  hv_WindowHandle1;
  ReadImage(&ho_Image, "D:/bb/tu/4.jpg");
  Rgb1ToGray(ho_Image, &ho_Image1);
  //將RGB圖像轉換為灰度圖像

  Threshold(ho_Image1, &ho_Region, 80, 90);


  Complement(ho_Region, &ho_RegionComplement);
  //區域的反選--獲取參數1之外的區域



  GetImageSize(ho_Image1, &hv_Width, &hv_Height);

  SetWindowAttr("background_color","black");
  OpenWindow(10,100,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_RegionComplement, HDevWindowStack::GetActive());

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM