Apply Erode Filter Effect on an Image

Steps to Apply Erode Filter Effect on an Image | OpenCV with Visual Studio in Windows 10. In this Tutorial, we are going to apply Erode Filter Effect on an image using OpenCV.
  1. First of all, Follow this tutorial to Install & Configure OpenCV with Visual Studio 2015

  2. Copy the Full Source Code to Apply Erode Filter on an Image from here:
  3. #include<opencv2/highgui/highgui.hpp>
    
    #include<iostream>
    
    int main()
    {
     //Load an Image
     IplImage* img = cvLoadImage("C:/Briefcase/Chess.jpg");
     cv::namedWindow("Image", CV_WINDOW_AUTOSIZE);
     cvShowImage("Image", img);
    
     //Erode Effect
     cvErode(img, img, 0, 2);
     cv::namedWindow("ErodeEffect", CV_WINDOW_AUTOSIZE);
     cvShowImage("ErodeEffect", img);
    
     //Wait Key press
     cvWaitKey(0); 
    
     //destroy
     cvDestroyWindow("Image");
     cvDestroyWindow("ErodeEffect");
    
     return 0;
    }
    
    OR
    Get ErodeEffect.cpp from Github:
    Download ErodeEffect.cpp

  4. Paste full source code and Run it (Ctrl+F5 or F5).

OUTPUT
Load an Image OpenCV
Load Image OpenCV
Erode Filter Effect OpenCV
Eroded Image OpenCV


Explaination : Function used: cvErode(img, img, 0, 2) - This function can process images and erode an image.

  • 1st parameter is the source image.
  • 2nd parameter is the destination or resultant image which is an eroded image.
  • 3rd parameter is the structuring element used. If it is 0, a 3 X 3 rectangular structuring element is used.
  • 4th parameter is the number of times, effect is applied.


Like, Share and Comment Below. You may also like these:




  • Apply Blur Filter Effect on an Image
  • Apply Dilate Filter Effect on an Image
  • Apply Negative Filter Effect on an Image


  • 2 comments: