• halcon开运算(先腐蚀再膨胀)


    开运算:对区域先进行腐蚀操作,然后对腐蚀的结果再进行膨胀操作,称为开运算
    开运算特点:具有与腐蚀相似的特点,但是能够防止区域腐蚀过度,能够很好的保持区域的形状。

    效果:能去除毛刺

    opening_circle区域圆开运算 

    在HDevelop中

    dev_update_off()
    
    read_image (Image, 'D:/bb/tu/1.jpg')
    rgb1_to_gray(Image,Image1)
    
    threshold (Image1, Region, 200, 230)
    opening_circle (Region, RegionOpening, 2.5)
    *区域圆开运算
    *参数1:要开运算的区域
    *参数2:输出区域
    *结构圆半径
    
    
    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(RegionOpening)

    在QtCreator中

        HObject  ho_Image, ho_Image1, ho_Region, ho_RegionOpening;
        HTuple  hv_Width, hv_Height, hv_WindowHandle;
        HTuple  hv_WindowHandle1;
        ReadImage(&ho_Image, "D:/bb/tu/1.jpg");
        Rgb1ToGray(ho_Image, &ho_Image1);
    
        Threshold(ho_Image1, &ho_Region, 200, 230);
        OpeningCircle(ho_Region, &ho_RegionOpening, 2.5);
        //区域圆开运算
        //参数1:要开运算的区域
        //参数2:输出区域
        //结构圆半径
    
    
        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_RegionOpening, HDevWindowStack::GetActive());

    opening_rectangle1区域矩形开运算 

    在HDevelop中

    dev_update_off()
    
    read_image (Image, 'D:/bb/tu/2.jpg')
    rgb1_to_gray(Image,Image1)
    
    threshold (Image1, Region, 200, 230)
    opening_rectangle1 (Region, RegionOpening, 10, 10)
    *区域矩形开运算
    *参数1:要开运算的区域
    *参数2:输出区域
    *结构矩形的宽和高
    
    
    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(RegionOpening)


    在Qt Creator中

        HObject  ho_Image, ho_Image1, ho_Region, ho_RegionOpening;
        HTuple  hv_Width, hv_Height, hv_WindowHandle;
        HTuple  hv_WindowHandle1;
        ReadImage(&ho_Image, "D:/bb/tu/2.jpg");
        Rgb1ToGray(ho_Image, &ho_Image1);
    
        Threshold(ho_Image1, &ho_Region, 200, 230);
        OpeningRectangle1(ho_Region, &ho_RegionOpening, 10, 10);
        //区域矩形开运算
        //参数1:要开运算的区域
        //参数2:输出区域
        //结构矩形的宽和高
    
    
        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_RegionOpening, HDevWindowStack::GetActive());

    gray_opening_rect图像开运算 

    在HDevelop中

    dev_update_off()
    
    read_image (Image, 'D:/bb/tu/2.jpg')
    rgb1_to_gray(Image,Image1)
    
    gray_opening_rect (Image1, ImageOpening, 11, 11)
    *图像开运算
    *参数1:要开运算的单通道图像
    *参数2:输出图像
    *结构矩形的宽和高
    
    
    get_image_size (Image1, Width, Height)
    dev_open_window(10,100,Width, Height,'black',WindowHandle)
    dev_display(Image1)
    dev_open_window(10,100,Width, Height,'black',WindowHandle1)
    dev_display(ImageOpening)


    在Qt Creator中

        HObject  ho_Image, ho_Image1, ho_ImageOpening;
        HTuple  hv_Width, hv_Height, hv_WindowHandle;
        HTuple  hv_WindowHandle1;
        ReadImage(&ho_Image, "D:/bb/tu/2.jpg");
        Rgb1ToGray(ho_Image, &ho_Image1);
    
        GrayOpeningRect(ho_Image1, &ho_ImageOpening, 11, 11);
        //图像开运算
        //参数1:要开运算的单通道图像
        //参数2:输出图像
        //结构矩形的宽和高
    
    
        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_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_ImageOpening, HDevWindowStack::GetActive());

    gray_opening_shape图像开运算

    在HDevelop中

    dev_update_off()
    
    read_image (Image, 'D:/bb/tu/2.jpg')
    rgb1_to_gray(Image,Image1)
    
    gray_opening_shape (Image1, ImageOpening, 11, 11, 'octagon')
    *图像开运算
    *参数1:要开运算的单通道图像
    *参数2:输出图像
    *参数3和参数4:结构矩形的宽和高
    *参数5:结构元形状
    *       'octagon'    八角形
    *       'rectangle'  矩形
    *       'rhombus'    棱形
    
    
    get_image_size (Image1, Width, Height)
    dev_open_window(10,100,Width, Height,'black',WindowHandle)
    dev_display(Image1)
    dev_open_window(10,100,Width, Height,'black',WindowHandle1)
    dev_display(ImageOpening)


    在Qt Creator中

        HObject  ho_Image, ho_Image1, ho_ImageOpening;
        HTuple  hv_Width, hv_Height, hv_WindowHandle;
        HTuple  hv_WindowHandle1;
        ReadImage(&ho_Image, "D:/bb/tu/2.jpg");
        Rgb1ToGray(ho_Image, &ho_Image1);
    
        GrayOpeningShape(ho_Image1, &ho_ImageOpening, 11, 11, "octagon");
        //图像开运算
        //参数1:要开运算的单通道图像
        //参数2:输出图像
        //参数3和参数4:结构矩形的宽和高
        //参数5:结构元形状
        //      'octagon'    八角形
        //      'rectangle'  矩形
        //      'rhombus'    棱形
    
    
        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_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_ImageOpening, HDevWindowStack::GetActive());

  • 相关阅读:
    uva 1362(区间dp+计数)
    uva 11174(排列组合+搜索)
    简单递推系列 uva习题
    基本计数方法系列 uva习题
    Codeforces Round #209 (Div. 2) Problem A Table(找规律)
    CodeChef November Challenge 2013 解题报告
    2012 chengdu现场赛 Browsing History HDU4464(简单字符串)
    CodeChef TechFest 2013 Cool Numbers(搜索)
    CodeChef Inscription 2013 Wonderland jewellery(简单题)
    页面滚动marquee标签
  • 原文地址:https://www.cnblogs.com/liming19680104/p/15978912.html
Copyright © 2020-2023  润新知