Opencv入门——通用形态学操作函数morphologyEx()

void cv::morphologyEx(
    cv::InputArray     src,
    cv::outputArray    dst,
    int                op,
    cv::InputArray     element,
    cv::Point          anchor     = cv::Point(-1,-1),
    int                iterations = 1,
    int                borderType = cv::BOEDERTY_DEFAULT
    const cv::Scalar& borderValue = cv::morpholoDefaultBorderValue()  
);
#include
#include

using namespace cv;
using namespace std;

int main()
{
	Mat img, dst, kernal;
	img = imread("D:\\OpenCV\\images\\lena_gray.jpg");
	if (img.empty())
	{
		cout << "image loading failed..." << endl;
		return -1;
	}

	namedWindow("input", WINDOW_AUTOSIZE);
	imshow("input", img);
	
	kernal = getStructuringElement(MORPH_RECT, Size(5, 5), Point(-1, -1));
	morphologyEx(img, dst, MORPH_BLACKHAT, kernal);
	imshow("output_img", dst);

	waitKey(0);
	return 0;
}

 

你可能感兴趣的:(OpenCV)