OpenCV之圖像腐蝕

#include "mainwindow.h"
#include <QApplication>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace cv;

#define WINDOW_NAME "[圖像]"
#define FuSi_NAME "[腐蝕]"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    system("chcp 65001");

    String imgpath = "F:\\MyCode\\dcq.jpg";
    Mat srcImage = imread(imgpath, 1);  // Mat tmpImage = srcImage;
    if(!srcImage.data){printf("讀取失敗");return -1;}
    namedWindow(WINDOW_NAME, WINDOW_AUTOSIZE);
    imshow(WINDOW_NAME, srcImage);

    Mat element = getStructuringElement(MORPH_RECT, Size(15, 15));
    Mat dstImage;
    erode(srcImage, dstImage, element);  //腐蝕
    namedWindow(FuSi_NAME, WINDOW_AUTOSIZE);
    imshow(FuSi_NAME, dstImage);
    waitKey(0);
    return a.exec();
}
相關文章
相關標籤/搜索