Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image convolution using an even-sized kernel

I was wondering, when you convolve with a 2x2 kernel, where do you put the result of the operation ? With a symmetric mask the result is applied to the pixel corresponding to the center of the mask; so what happens when a mask doesn't have a center ? Besides, why would someone use an even sized kernel ?

like image 624
darkpirate Avatar asked Oct 29 '15 13:10

darkpirate


People also ask

Can kernel size be even in CNN?

Except for scaling, few works have implemented even-sized kernels as basic building blocks for their CNN models.

Does kernel size have to be odd?

Save this answer. Show activity on this post. The kernel doesn't need to be odd.

How do you determine the size of the convolution kernel?

A common choice is to keep the kernel size at 3x3 or 5x5. The first convolutional layer is often kept larger. Its size is less important as there is only one first layer, and it has fewer input channels: 3, 1 by color.

What is kernel in image convolution?

In image processing, a kernel, convolution matrix, or mask is a small matrix used for blurring, sharpening, embossing, edge detection, and more. This is accomplished by doing a convolution between the kernel and an image.


1 Answers

It doesn't really matter, but whichever approach you use you may get a 0.5 pixel shift in the resulting image. You can see why this might happen intuitively by considering your 2x2 example as 3x3 with zero padding, e.g.

 k00  k01   0
 k10  k11   0
  0    0    0

As for why you might want to use an even size - one application of convolution is cross-correlation (flipping one of the images changes convolution to correlation and vice versa). Cross-correlation has many uses, including template matching (finding a target image within a larger image), so if your template has an even size then the resulting convolution/correlation will also involve an even sized "kernel".

like image 53
Paul R Avatar answered Oct 21 '22 16:10

Paul R