[Learning OpenCV] image corrosion, expansion, opening and shutting operation

Source: Internet
Author: User
#include "cv.h"
#include "highgui.h"

using namespace CV;

int main (int argc, char* argv[])
{
        Mat src = imread ("misaka.jpg");
        Mat DST;
        
        Input image
        //output image
        //cell size, here is the 8-bit unit
        //corrosion position of the 5*5, a negative core
        ///Corrosion frequency two times
        Erode (Src,dst,mat (5,5,cv_8u), Point ( -1,-1), 2);
        Imwrite ("Erode.jpg", DST);

        Input image
        //output image
        //cell size, here is the 5*5 8-bit unit
        //expansion position, for negative Core center
        //Expansion times two times
        dilate (Src,dst,mat (5,5,cv_8u ), point ( -1,-1), 2);
        Imwrite ("Dilate.jpg", DST);

        Input image
        //output image
        //definition operation: Morph_open for open operation, Morph_close for closed Operation
        //unit size, here is 3*3 8-bit Unit
        //opening/closing operation position
        // Opening and closing operation number
        Morphologyex (Src,dst,morph_open,mat (3,3,cv_8u), point ( -1,-1), 1);
        Imwrite ("Open.jpg", DST);

        Morphologyex (Src,dst,morph_close,mat (3,3,cv_8u), point ( -1,-1), 1);
        Imwrite ("Close.jpg", DST);

        Imshow ("DST", DST);
        Waitkey ();

        return 0;
}

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.