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

	// garbage collection
	return 0;

Input image

Output Image after smoothing

This entry was posted in Digital Image Processing.

Leave a Reply

Your email address will not be published. Required fields are marked *