Saturday, June 2, 2012

Smoothing Techniques in OpenCV

Hi,

This post is an additional note to official OpenCV tutorial : Smoothing Images

( Its corresponding Python code can be found here : smoothing.py )

Below I would like to show you the results I got when I applied four smoothing techniques in OpenCV, ie cv2.blur, cv2.GaussianBlur, cv2.medianBlur and cv2.bilateralFilter. Kernel size, I used in all cases were 9. See the result below :

Original Image:

Original Image
After Homogeneous Blur, cv2.blur() :

Result of blurring
After Gaussian Blur , cv2.GaussianBlur():

Result of Gaussian Filter
It is much more clear than previous.

After median blur, cv2.medianBlur() :

After median blur
 It has become somewhat like a painting. See eye, it has become completely black.

Finally, after bilateral filter :


This result has high similarity with original image. It is because, it doesn't smooth the edge, instead smooth small noises leaving edges same way. So to see difference, zoom image to left face and check carefully. Then you will understand, face part will have become much more smoother, in short, much more glamorous. There is a nice explanation of bilateral filter at this link : Bilateral Filtering.

But the main problem is that, it takes more time than other filters. 


Regards,
ARK