Search
 
SCRIPT & CODE EXAMPLE
 

CPP

erosion and dilation c++

// C++ program to implement the erosion
// and dilation
#include <iostream>
#include <opencv2/core/core.hpp>
  
// Library to include for drawing shapes
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
  
// Driver Code
int main(int argc, char** argv)
{
    // Reading the Image
    Mat image = imread("C:/Users/harsh/Downloads/geeks.png",
                       IMREAD_GRAYSCALE);
  
    // Check if the image is created
    // successfully or not
    if (!image.data) {
        std::cout << "Could not open or find"
                  << " the image
";
        return 0;
    }
  
    // Create a structuring element (SE)
    int morph_size = 2;
    Mat element = getStructuringElement(
        MORPH_RECT, Size(2 * morph_size + 1,
                         2 * morph_size + 1),
        Point(morph_size, morph_size));
    Mat erod, dill;
  
    // For Erosion
    erode(image, erod, element,
          Point(-1, -1), 1);
  
    // For Dilation
    dilate(image, dill, element,
           Point(-1, -1), 1);
  
    // Display the image
    imshow("source", image);
    imshow("erosion", erod);
    imshow("dilate", dill);
    waitKey();
  
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: grpah class data structure 
Cpp :: constant pointer c++ 
Cpp :: c++ pass argument to singleton 
Cpp :: logisch und 
Cpp :: convert set to vector c++ 
Cpp :: collections c# vs c++ 
Cpp :: every number is coming thrice except one 
Cpp :: 3d array in c++ 
Cpp :: what are various sections of process 
Cpp :: gestd::getline with wstring 
Cpp :: c++ string to wstring 
Cpp :: delete 2d dynamic array c++ 
Cpp :: class Solution { public: vector<vector<int threeSum(vector<int& nums) meaning 
Cpp :: c++ enum rand 
Cpp :: c++ in linux 
Cpp :: c++ remove space from string 
Cpp :: prime number program in c c++ 
Cpp :: arduino led code 
Cpp :: unclebigbay 
Cpp :: string to int arduino 
Cpp :: insertion sort c++ 
Cpp :: c++ print number not in scientific notation 
Cpp :: kruskal in c++ 
Cpp :: taking a vector in c++ containing element 
Cpp :: conditional operator in cpp 
Cpp :: c++ char to uppercase 
Cpp :: initialize whole array to 0 c++ 
Cpp :: data types ranges c++ 
Cpp :: int to string c++ 
Cpp :: find max value in array c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =