Let's learn the meaning of some terms used when discussing image filtering techniques, kernel and convolution.

### Kernel

Kernel is a matrix with an odd height and an odd width. It is also known as convolution matrix, mask or filter. Kernels are named based on their value distribution. Kernel is used to define a neighborhood of a pixel in a image filtering operation. Some of the popular kernels are Normalized box filter, Gaussian kernel, Laplacian kernel, edge detecting kernels etc. Kernels can be defined with different sizes. But large kernels result in a large processing time.

This is a 3 x 3 Normalized Box filter. This kernel is used in homogeneous smoothing (blurring).

This is a 3 x 3 Gaussian kernel used in Gaussian smoothing (blurring).

2-D Gaussian Function |

x, y is the coordinates of the kernel where the origin is placed at the center. (i.e. x = 0 and y = 0 at the center element of the kernel.)

**σ**is the standard deviation of the Gaussian distribution. For larger standard deviations, larger kernels are required in order to accurately perform the Gaussian smoothing. The standard deviation of the following 5 x 5 Gaussian kernel is 1.### Convolution

Convolution is a mathematical operation performed on images by sliding a kernel across the whole image and calculating new values for each pixels based on the value of the kernel and the value of overlapping pixels of original image.

C_{22}= (K_{11}x A_{11}+ K_{12 }x A_{12}+ K_{13}x A_{13}) + (K_{21}x A_{21 }+ K_{22}x A_{22}+ K_{23}x A_{23}) + (K_{31}x A_{31}+ K_{32}x A_{32}+ K_{33}x A_{33}) C_{23}= (K_{11}x A_{12}+ K_{12}x A_{13}+ K_{13}x A_{14}) + (K_{21}x A_{22}+ K_{22}x A_{23}+ K_{23}x A_{24}) + (K_{31}x A_{32}+ K_{32}x A_{33}+ K_{33}x A_{34}) C_{24}= (K_{11}x A_{13}+ K_{12}x A_{14}+ K_{13}x A_{15}) + (K_{21}x A_{23}+ K_{22}x A_{24}+ K_{23}x A_{25}) + (K_{31}x A_{33}+ K_{32}x A_{34}+ K_{33}x A_{35}) C_{32}= (K_{11}x A_{21}+ K_{12}x A_{22}+ K_{13}x A_{23}) + (K_{21}x A_{31}+ K_{22}x A_{32}+ K_{23}x A_{33}) + (K_{31}x A_{41}+ K_{32}x A_{42}+ K_{33}x A_{43}) C_{33}= (K_{11}x A_{22}+ K_{12}x A_{23}+ K_{13}x A_{24}) + (K_{21}x A_{32}+ K_{22}x A_{33}+ K_{23}x A_{34}) + (K_{31}x A_{42}+ K_{32}x A_{43}+ K_{33}x A_{44})

In the same way C34, can be calculated in the convolved image. But other values in the boundary of the convolved image (e.g C11, C12, etc) cannot be calculated in the same way because the kernel is partially overlapped with the original image at the boundary. Therefore non-overlapped non-existing pixel values should be calculated in order to determine the pixel values at the boundaries of the convolved image. There are various techniques to handle this boundary values, but I'm not going to discuss it in this tutorial.

After learning bit of theory of image filtering, let's learn some use cases of image filtering techniques with OpenCV C++ examples.

- Smooth / Blur Images

When an image is acquired by a camera or other method, the image may be corrupted by random dots and noises. Smoothing/blurring is one of image processing techniques to eliminate such imperfections and improve the image. Image smoothing techniques can be applied even for each frames of a video to eliminate imperfections and improve the video.

- Homogeneous Blur
- Gaussian Blur
- Median Smoothing
- Bilateral Smoothing

Thanx for excellent tutorial!

ReplyDeleteBut, could you give a link, how are the boundary pixels counted? Just for better undrstanding

This comment has been removed by the author.

DeleteHi, Thanks for the tutorial, I have a question here, how those pixel values of 5*5 matrix calculated, or those are standard

ReplyDeleteChoose your favourite image from your device gallery or capture the real picture with your smartphone camera to create a drawing photo sketch & pencil sketch photo editor & set some stylish colour drawing effect and sparkle effect.

ReplyDeleteWhen you make a beautiful pencil sketch of your image then you feel it’s the best photo sketch - convert photo to sketch app and sparkle effect in the world.

Well, I was looking for Law Essay Writing Services for my essay when I landed on your post. However, I know it is not helping me out in my essay but I totally love the way you have described it because during my whole academic career, I could not learn matrices and this was the reason I always used to hate maths.

ReplyDeleteamazing thoughts love the way you've write keep it up

ReplyDeletetake my online exam check assignment help.

The perks of hiring someone to do my online exam now are numerous. I mean what can go wrong if you have an extra helping hand, might I say a helping mind.

ReplyDeletethat was an amazing post

ReplyDeleteCarta de Conducao

Rijbewijs Kopen

Buy driving license

Comprar Licencia de Conducir

Permis de Conduire

I needed to thank you for this incredible read!! Delhi Call Lady I certainly partaking in every single piece of it I have you bookmarked to look at new stuff you post.

ReplyDeletekoop rijbewijs online geregistreerd in de gemeente binnen 5 tot 7 werkdagen tegen een goedkope prijs zonder examens

ReplyDeleteRijbewijs Kopen België

Rijbewijs Kopen

Rijbewijs b Kopen

Rijbewijs Online Kopen

ReplyDeleteComprar carta conducao online sem exames no prazo de 5 a 7 dias úteis válido no imt de portugal

Comprar Carta Condução

carta condução mota

kjøpe førerkort

buy UK driver's license

Comprar Carta de Condução

Carta de Condução Preços

Comprar Carta Condução Verdadeira

Comprar Carta de Mota

Führerschein in Deutschland im Datenbanksystem registriert ohne Prüfungen innerhalb von 5 bis 7 Werktagen kaufen

ReplyDeleteFührerschein kaufen

eu führerschein kaufen

registrierten Führerschein kaufen

echten führerschein kaufen

deutschen Führerschein kaufen

führerschein kaufen legal

Acquista la patente di guida sul nostro sito Web valida nel sistema di database senza esami entro 5-7 giorni lavorativi

ReplyDeletecomprare patente

acquisti la patente guida

come acquistare patente guida

kup prawo jazdy

Comprar Carta de Condução

acheter permis de conduire

köp körkort

acquiste patente di guida

Comprar carnet de conducir en nuestra web inscrito en el Dgt en un plazo de 5 a 7 días hábiles sin exámenes y podrá conducir libremente en España y otros países sin ningún problema señor

ReplyDeleteComprar Licencia de Conducir

Comprar Carnet de Conducir

Comprar Licencia Conducir Legal

Comprar carnet de conducir

comprar licencias de conducir

comprar carnet conducir dgt

comprar licencia de conducir

Cum să cumpărați permisul de conducere online în 5 până la 7 zile fără examene

ReplyDeletecumpăra permis de conducere

cumpărați permisul conducere online

cumpara permis conducere romanesc

cumpăra permis conducere înregistrat

cumpăra permis conducere România