Apply Dilate Filter Effect on an Image

Steps to Apply Dilate Filter Effect on an Image | OpenCV with Visual Studio in Windows 10. In this Tutorial, we are going to apply Dilate 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 Dilate 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);
    
     //Dilate Effect
     cvDilate(img, img, 0, 2);
     cv::namedWindow("DilateEffect", CV_WINDOW_AUTOSIZE);
     cvShowImage("DilateEffect", img);
    
     //Wait Key press
     cvWaitKey(0);
    
     //destroy
     cvDestroyWindow("Image");
     cvDestroyWindow("DilateEffect");
    
     return 0;
    }
    
    OR
    Get DilateEffect.cpp from Github:
    Download DilateEffect.cpp

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

OUTPUT
Load an Image OpenCV
Load Image OpenCV
Dilate Filter Effect OpenCV
Dilated Image OpenCV


Explaination : Function used: cvDilate(img, img, 0, 2) - This function can process images and dilate an image.
  • 1st parameter is the source image.
  • 2nd parameter is the destination or resultant image which is a dilated 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 Erode Filter Effect on an Image
  • Apply Negative Filter Effect on an Image


  • 1 comment: