腐蚀结果

原图像
Opencv C++成长之路(十):图像腐蚀
腐蚀处理后图像
Opencv C++成长之路(十):图像腐蚀

Show me the code

#include <opencv2/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <string>

using namespace std;

int main() {
    // 图像路径
    const string FILENAME = "xxx.jpg";
    
    // 读取图像
    const cv::Mat origin = cv::imread(FILENAME);
    
    // 设置腐蚀窗大小,生成腐蚀窗
    const int winRow = 25;
    const int winCol = 25;
    cv::Mat element = cv::getStructuringElement(cv::MORPH_ERODE, 
    											cv::Size(winCol, winRow));
    
    //图像腐蚀
    cv::Mat result;
    cv::erode(origin,
              result,
              element);
    
    //显示原图和腐蚀结果
    cv::imshow("Origin Image", origin);
    cv::imshow("Result", result);
    
    cv::waitKey(0);
}

相关文章:

  • 2021-09-20
  • 2021-05-13
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
猜你喜欢
  • 2021-11-13
  • 2021-07-11
  • 2021-08-25
  • 2021-10-05
  • 2021-12-15
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案