Convolution
Convolution — Convolution slides a small grid of weights (a kernel) across an input, computing a weighted sum at every position. The same kernel is reused everywhere, so it detects one local pattern — an edge, a blob, a texture — wherever it appears in the image.
A convolution is a tiny stencil that slides across an image, and at every stop it multiplies-and-adds the pixels underneath it. Reuse one small kernel across the whole picture and you get a feature detector that finds its pattern anywhere — the core operation that makes CNNs see.
Input · the kernel window slides → Output feature map
The same little grid of weights slides over every position, multiplying and adding the pixels underneath. An edge kernel lights up boundaries; a blur kernel averages them away — switch to Blur and watch the sharp rim it needs to detect dissolve.
The same little grid of weights slides over every position, multiplying and adding the pixels underneath. An edge kernel lights up boundaries; a blur kernel averages them away — switch to Blur and watch the sharp rim it needs to detect dissolve.
The idea in plain words
A convolution is a tiny stencil — a small grid of weights called a kernel — that slides across an image. At every stop it multiplies the pixels underneath it by its weights and adds them up, writing one number into an output grid called a feature map.
The trick is that the same kernel is reused at every position. So a kernel that responds to a vertical edge finds vertical edges anywhere in the picture — this reuse is called weight sharing, and it’s what makes convolutional networks efficient. Swap the kernel and the same machinery becomes an edge detector, a sharpener, or a blur.
Now, the math
Each output pixel is the weighted sum of a small window of the input (cross-correlation, the operation CNNs actually use):
- the input image (or previous feature map).
- the kernel weights — the same grid reused at every position.
- one pixel of the output feature map.
- a bias added to every position.
▸ Show the derivation
With a kernel and no padding, an input produces an output — the kernel can’t hang off the edge, so the map shrinks by . Adding a border of zeros (padding) keeps the size the same; taking bigger steps (stride) shrinks it faster. Because every output reuses one small set of weights, a convolution has far fewer parameters than a fully-connected layer over the same pixels.
Now Break It
Try this: A blur kernel on a sharp edge washes out the very structure the next layer needs.
Control: Kernel preset (switch to blur)
What happens: Wrong kernel! A blur smooths away the edges — the feature the next layer was counting on is gone.
Where convolution is used
Convolution is the workhorse behind almost everything computers do with images. Photo apps use learned kernels to sharpen, denoise, and blur; medical-imaging systems convolve scans to highlight tumors and fractures; self-driving cars run convolutions over camera frames to find lane lines and pedestrians. The same operation powers document scanning (detecting text edges), satellite analysis, and the first layers of every convolutional network that classifies or generates images.
A common misconception is that a convolution “looks at the whole image.” It does not — each output pixel only sees a tiny local window (the receptive field). Global understanding is built up by stacking convolutions, so deeper layers indirectly see more of the image. Another trap is confusing convolution with the fully-connected layers of an MLP: because a kernel reuses the same weights everywhere, it has far fewer parameters and — crucially — detects its pattern anywhere it appears, which a dense layer cannot do. Finally, note the sign convention: deep-learning “convolution” is really cross-correlation (no kernel flip), which is why the interactive slides the kernel without mirroring it.
Frequently asked questions
What is a kernel (or filter) in convolution?
What is the difference between convolution and cross-correlation?
What do padding and stride do?
Why does the output feature map get smaller than the input?
Why use convolution instead of a fully-connected layer for images?
Written & reviewed by the ML Visualization team · Last updated .