# What is the difference between kernel and filter

What is the difference between kernel and filter? (Not for CNN, in general)

• Kernel is the matrix a digital filter is using to calculate the result (the matrix which is convolved with the source data). Oct 30, 2019 at 15:38
• What I understand is filter is a more general terms including kernel, because filter can be a matrix, too. Is it correct? Oct 30, 2019 at 15:45
• Filter is a thing that is working by applying the kernel. The difference is as between a painter and a paint. Painter is not more general than paint. It's just a different thing. Oct 30, 2019 at 15:47
• For image processing: A filter would be the result of using a kernel (or masking). CNN's use, surprise surprise, convolution but that's an entirely different algorithm since there are weights and activation functions, etc.
– user103380
Oct 30, 2019 at 16:15
• A filter is more of a general transfer function or model concept, while a kernel has a specific and unique realization (ex. gaussian kernel, Laplacian, etc.). Kernels are different models to realize filters, but not the other way around.
– pat
Sep 11, 2021 at 20:29

A kernel is the 2 dimensional matrix for 2d convolution (or 1d also), A kernel defines the size of the convolution. A filter is the values stored in the kernel matrix. A kernel matrix doesn't have to be a filter, for example if you had a kernel with

$$\begin{bmatrix}0&0&0\\0&1&0\\0&0&0\end{bmatrix}$$

the kernal above wouldn't filter anything, but leave you with what you started after convolution.

You can also make edge detectors, like the one below $$\begin{bmatrix}1&0&-1\\1&0&-1\\1&0&-1\end{bmatrix}$$

• A filter is the values stored in the kernel matrix - this doesn't sound right. Oct 30, 2019 at 16:18
• You don't have to build a filter with a kernel matrix, Oct 30, 2019 at 16:22
• The kernel is the thing that stores the values for convolution. Oct 30, 2019 at 16:23
• You don't, but it doesn't make filter to be the values of the matrix. Kernel is a property of a filter, not vice versa Oct 30, 2019 at 16:24
• In image processing, a kernel, convolution matrix, or mask is a small matrix. -wikipedia Oct 30, 2019 at 16:25