Ask Your Question
5

Smoothing image-better way of doing that

asked 2012-08-13 17:47:32 -0600

aeromind gravatar image

updated 2020-11-29 07:22:27 -0600

Actually I'm trying to reduce noise in camera capture, and one way could be using smooth. But i dont know what method of smoothing to use,because there are many types ( For example: gaussian, blur,median, and others...). Which one is better to get performance and quality together ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
12

answered 2012-08-14 01:43:34 -0600

sammy gravatar image

updated 2012-08-14 03:36:18 -0600

There are different kinds of filters for different kinds of noise - you should select the proper filter for your noise. Keep in mind that all filters come with a reduction in image resolution - they are mainly an average operator, so even that you have the same destination resolution, some information is gone. More exactly, your image will become fuzzy.

The bigger your kernel, the more visible are the results: noise is reduced by a factor of width*height of your filter kernel, but fuzziness also increases when the kernel size increases.

Some kinds of filters

  • Gaussian. Good to remove additive noise (some pixels that are a bit higher or lower than the rest).

  • There are different additive noise models: white, gaussian, etc. While for the gaussian one, the gaussian filter is the method of choice, for white noise you best use a "flat" filter, that is, one that merely averages the pixels in a neighbourhood, with equal weights. The technical name for it is box filter, and it has a nice nickname in OpenCV: blur(). It is quite simplistic, because in most cases the noise found in a picture is not white, but its main advantage is speed - it is the fastest filter in the list.

  • The two filters above have a significant problem: they blur the image more than one would like. Especially for large kernels, the image becomes foggy. They smooth both the noise and the edges. To solve this issue, the bilateral filter has been developed -it has a gaussian kernel that is adapted locally to preserve edges. While it is one of the best methods out there for noise removal, it is also a performance killer - it's not well-fitted for real-time applications.

  • Median filter. Excellent to remove "salt and pepper noise" - pixels that are 0 or 255, instead of the expected value. Images that require median filtering have small white or black dots in them. It takes all the pixels in a neighborhood, sorts them, and takes the median value (the one in the middle of the sorted vector). Look here for a nice example. It is usually employed in cheap camera hardware to remove "burned" pixels.

To have a complete list of ways to remove noise, I should also add a different but very useful technique. Image subsampling (resizing to a smaller size) is often performed as a pre-processing step in image analysis, not least for performance reasons ( Object detection is slow? ). A good shrinking algorithm will also remove noise: bilinear, bicubic and area-based resize will give you a smaller, noise-free image. The best out there is the cv::INTER_AREA flag.

Final note: this is just a short introduction in filtering theory. If you are interested to know more, look for some online university courses on image processing: stanford, mit, cmu, etc. Or maybe someone else will recommend you a good bibliography.

edit flag offensive delete link more

Comments

1

A very nice answer for a nice common question :)

Rui Marques gravatar imageRui Marques ( 2012-08-14 04:06:02 -0600 )edit

thanks! Thats a pretty good and complete answer

aeromind gravatar imageaeromind ( 2012-08-14 11:55:20 -0600 )edit

Does the OpenCV implementation of the Bilateral Filter considered fast? Thank You.

Royi gravatar imageRoyi ( 2012-10-15 02:23:17 -0600 )edit

Just run the perf test and check it yourself: http://opencv.willowgarage.com/wiki/AnalyzePerfTestsLogs

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-10-15 03:21:25 -0600 )edit

I meant comparing to other implementations, not by itself.

Royi gravatar imageRoyi ( 2012-10-16 02:20:58 -0600 )edit
1

@Drazick Run the other implementation, see the result, and compare it with the perf test from Opencv

sammy gravatar imagesammy ( 2012-10-16 02:47:19 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-08-13 17:47:32 -0600

Seen: 4,544 times

Last updated: Aug 14 '12