• Opencv3 图片膨胀与腐蚀


    #include <iostream>
    #include <opencv2/opencv.hpp>

    using namespace std;
    using namespace cv;

    int elementSize = 3;
    int maxSize = 260;

    int Demo_Load_Img();

    //图片膨胀
    void Get_Img_Struct_Element_Dilate(int, void*);

    //图片腐蚀
    void Get_Img_Struct_Element_Erode(int, void*);

    Mat img1, img2, structElement;
    char win1[] = "window1";
    char win2[] = "window2";

    int Demo_Load_Img()
    {
      img1 = imread("D://images//4.jpg");
      imshow(win1,img1);
      //图片膨胀
      //createTrackbar("Element Size:",win1,&elementSize,maxSize, Get_Img_Struct_Element_Dilate);
      ////图片膨胀
      //Get_Img_Struct_Element_Dilate(0,0);

      //图片腐蚀
      createTrackbar("Element Size:", win1, &elementSize, maxSize, Get_Img_Struct_Element_Erode);
      //图片腐蚀
      Get_Img_Struct_Element_Erode(0, 0);


      return 0;
    }

    //图片膨胀
    void Get_Img_Struct_Element_Dilate(int,void*)
    {
      int size_1 = elementSize * 2 + 1;
      structElement = getStructuringElement(MORPH_RECT,Size(size_1,size_1),Point(-1,-1));
      //膨胀
      dilate(img1,img2,structElement,Point(-1,-1),1);
      imshow(win2,img2);
    }

    void Get_Img_Struct_Element_Erode(int,void*)
    {
      int size_1 = elementSize * 2 + 1;
      structElement = getStructuringElement(MORPH_RECT, Size(size_1, size_1), Point(-1, -1));
      //腐蚀
      erode(img1, img2, structElement);
      imshow(win2, img2);
    }

    int main()
    {
      Demo_Load_Img();


      waitKey(0);
      return 0;
    }

  • 相关阅读:
    springcloud(三)
    springcloud(二)
    spring-cloud(一)
    springboot(三)
    springboot(二)
    springboot(一)
    dubbox
    SpringBoot终章(整合小型进销系统)
    SpringBoot第三节(thymeleaf的配置与SpringBoot注解大全)
    SpringBoot--集成Shiro
  • 原文地址:https://www.cnblogs.com/herd/p/9734041.html
Copyright © 2020-2023  润新知