Published on

Why is Odd sized kernel preferred over Even sized kernel?

Authors

Last Modified : Tuesday, April 30, 2024

I hope everyone will be aware of the role of kernels in Computer Vision. You must have observed that We generally use Odd sizes of Kernel (1x1, 3x3, 5,5, 7x7 many other in the same series). But Why only Odd shapes? What’s the reason behind that, I will explain it here.

Convolution using 3x3 kernel with no Padding

We always apply Padding to our images to convolve more and to get the best features, so that’s why Padding becomes important to be added be before Convolution. Output Feature map size after Padding can be calculated with the given formula:

o/p_size = img_size - kernel_size +1 +(2* padding_size)

Using Padding, we want our o/p_size of Feature map to be the same as img_size, this will help us find the padding_size with the help of kernel_size. See the formula which is derived from above.

padding_size =(kernel_size - 1) / 2

Constant Padding (fill all the red pixels in the image with 0)

You must be thinking, Why am I telling about padding diverting from the question of Odd Kernel. All the above points which I am including are connected to prove that Why we prefer to use Odd kernels over Even kernels.

If we put any kernel_size of Even size then padding_size will be a decimal number, How we will apply decimal padding to the Initial image is impossible to do. And if we use any kernel_size of Odd size then padding_size will be any Whole number, Padding of that value can be applied. That’s why we use Odd kernel size.

Other than that, Even sized kernels can also be used but those Images cannot be padded means No Padding (Valid Padding) is necessary for it.

Another reason for using Odd sized kernel is that all the previous layer pixels would be Symmetric around the Output pixel. Without this Symmetric, we will account for distortion across all the layers which happen when we use Even sized kernel. Therefore to promote simplicity to implementation we skip Even-sized kernel.

Symmetric Output(Credits: Wikipedia)

Another reason for not using Even sized kernel is that if we think of Convolution as an interpolation(putting one value that can be used to estimate others) from given pixels to the center pixel, We cannot interpolate to center pixels using Even- sized kernel.

Interpolation of pixels to Center pixel (Credits: SabyaSachi Sahoo)

I hope these three reasons are enough to make to understand about the use of Odd-sized kernels over Even-sized kernels.

Thank you for reading it.