Gaussian image smoothing using OpenCV
Image smoothing is often used in digital image processing to reduce noise or camera artifacts. An example of a common algortihm used to perform image smoothing is Gaussian. Gaussian filtering is done by convolving each pixel in the input image with a Gaussian Kernal and then summing to produce the output image.
#include "stdafx.h" #include "cv.h" #include "highgui.h" int _tmain(int argc, _TCHAR* argv[]) { // open and display input image IplImage* input = cvLoadImage("test.jpg"); cvNamedWindow("Input", CV_WINDOW_AUTOSIZE); cvShowImage("Input", input); // create the output IplImage* output = cvCreateImage(cvSize(input->width, input->height), input->depth, input->nChannels); cvSmooth(input, output, CV_GAUSSIAN, 9); // display the output image cvNamedWindow("Output", CV_WINDOW_AUTOSIZE); cvShowImage("Output", output); // wait for user cvWaitKey(0); // garbage collection cvReleaseImage(&input); cvReleaseImage(&output); cvDestroyWindow("Input"); cvDestroyWindow("Output"); return 0; }