Apply Blur Filter Effect on an Image

Steps to Apply Blur Filter Effect on an Image | OpenCV with Visual Studio in Windows 10. In this Tutorial, we are going to apply Blur 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 Blur Filter on an Image from here:
  3. #include<opencv2/highgui/highgui.hpp>
    #include<opencv2/imgproc/imgproc.hpp>
    
    using namespace cv;
    
    int main()
    {
     //Load an Image
     Mat img = imread("C:/Briefcase/Chess.jpg", CV_LOAD_IMAGE_COLOR);
     namedWindow("Image", CV_WINDOW_AUTOSIZE);
     imshow("Image", img);
    
     //Blur Effect
     GaussianBlur(img, img, cv::Size(3, 3), 0);
     namedWindow("BlurEffect", CV_WINDOW_AUTOSIZE);
     imshow("BlurEffect", img);
    
     //Wait Key press
     cvWaitKey(0);
    
     //destroy
     cvDestroyWindow("Image");
     cvDestroyWindow("BlurEffect");
    
     return 0;
    }
    
    OR
    Get BlurEffect.cpp from Github:
    Download BlurEffect.cpp

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

OUTPUT
Load an Image OpenCV
Load Image OpenCV
Blur Filter Effect OpenCV
Blur Image OpenCV


Explaination : Function used: GaussianBlur(img, img, cv::Size(3, 3), 0) - This function can process images and blur an image.
  • 1st parameter is the source image.
  • 2nd parameter is the destination or resultant image which is a blur image.
  • 3rd parameter is the structuring element used.
  • 4th parameter is gaussian standard deviation in x direction (sigmaX)


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


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


  • 2 comments:

    1. Thankyou.. useful but also post on 'how can i add blur effect on a video'

      ReplyDelete
    2. if its a live vide follow this link;

      http://opencv-cpp.blogspot.com/2016/11/canny-edge-detection-on-webcam.html

      ReplyDelete