Created
October 26, 2013 15:37
-
-
Save sumit4iit/7170825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include "cv.h" | |
#include "highgui.h" | |
#include <cstring> | |
using namespace cv; | |
using namespace std; | |
int main() | |
{ | |
string path = "res/download.jpg"; | |
Mat src = imread(path,CV_LOAD_IMAGE_ANYCOLOR); | |
if(!src.data) | |
{ | |
cout<<"fail\n"; | |
return -1; | |
} | |
Mat blurBlock, gaussian, median, bilateral; | |
int kernel_size = 5; | |
// Blur operator. | |
// Size defines size of kernel | |
// Point is an anchor point , and here point -1,-1 defines a center point of the mask. | |
// BORDER_DEFAULT specifies the border type for padding image. | |
// For more explanation please read my post on filter2d. | |
// Blur operator. | |
blur(src,blurBlock,Size(kernel_size,kernel_size), Point(-1,-1), BORDER_DEFAULT); | |
// Gaussian Filter | |
// The two 0s after Size(kernel_size,kernel_size) specify the valuse of sigma1 and sigma2. | |
// Here 0 and 0 represent that value of sigmax and sigmay should be calculated from the dimension of kernel | |
GaussianBlur(src,gaussian,Size(kernel_size,kernel_size), 0, 0, BORDER_DEFAULT); | |
// Median Blur | |
// Default size of kernel. | |
medianBlur(src, median, kernel_size); | |
// Display the results | |
namedWindow("Input",CV_WINDOW_AUTOSIZE); | |
namedWindow("Block",CV_WINDOW_AUTOSIZE); | |
namedWindow("Gaussian",CV_WINDOW_AUTOSIZE); | |
namedWindow("Median",CV_WINDOW_AUTOSIZE); | |
imshow("Input",src); | |
imshow("Block",blurBlock); | |
imshow("Gaussian",gaussian); | |
imshow("Median",median); | |
// wait for keypress event. | |
waitKey(0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment