Development of OpenCV 2.4.11 under Qt 5.3 (14) open and closed operations

Source: Internet
Author: User
Tags image line

The code is as follows:

#include <QCoreApplication> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp > #include <opencv2/imgproc/imgproc.hpp>using namespace cv;int main () {       Mat src = imread ("Lena.jpg", 0);    Mat DST, close, open;    Mat Element (5, 5, cv_8u, Scalar (1));    Threshold (SRC, DST, 255, THRESH_BINARY_INV);    Namedwindow ("DST", 0);    Imshow ("DST", DST);    Morphologyex (DST, close, morph_close, Element);//closed Operation    Namedwindow ("Close", 0);    Imshow ("Close", close);    Morphologyex (DST, open, morph_open, Element);//Open Operation    Namedwindow ("open", 0);    Imshow ("Open", open);    Waitkey (0);}

Function Description:

1, Morphologyex function in fact, with the use of corrosion and expansion of the same, the definition of closed operation on the image line expansion and corrosion, open operation is the opposite.

Closed operation: It is used to fill a small cavity inside an object, to connect adjacent objects, to smooth its boundary without significantly altering its area.

Open operation: It is used to eliminate small objects, to separate objects at slender points, to smooth the boundaries of larger objects without significantly altering their area.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Development of OpenCV 2.4.11 under Qt 5.3 (14) open and closed operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.