IT Vizag
← Computer Vision in Practice
Loading video…

Computer Vision in Practice · Lesson 3 of 15 · 2 min read · 6 min video

Convolutions, visually

How small filters slide over an image to find edges, textures and shapes.

📄 Download slides (PDF)

How does a model find an edge, or a corner, or the round shape of a wheel? With convolutions: small filters that slide across the image looking for one pattern each.

A filter is a tiny pattern detector

A filter (or kernel) is a small grid of numbers, often 3 × 3. To apply it:

  1. Place it over a 3 × 3 patch of the image
  2. Multiply each filter number by the pixel under it, and add them all up
  3. Write that single number into the output
  4. Slide one step to the right and repeat, across the whole image

The output is a feature map: bright where the pattern was found, dark where it wasn't.

An edge detector

import numpy as np
from scipy.signal import convolve2d

vertical_edge = np.array([[-1, 0, 1],
                          [-1, 0, 1],
                          [-1, 0, 1]])
feature_map = convolve2d(gray_image, vertical_edge, mode="same")

This filter gives a big number where the left side of the patch is dark and the right side is bright, which is exactly a vertical edge, like the side of a building.

Stride and padding

  • Stride: how far the filter moves each step. A stride of 2 halves the output size
  • Padding: adding a border of zeros so the output keeps the same size and edges aren't lost

The big idea: learned filters

In classic vision, people designed filters by hand. In a convolutional neural network, the filter numbers are weights, and training learns them. The network discovers its own edge, texture and shape detectors, often better than anything hand-designed.

Why convolutions suit images

  • Local: each output looks at a small neighbourhood, and nearby pixels belong together
  • Shared weights: the same filter is used everywhere, so a cat's ear is recognised anywhere in the picture
  • Efficient: a 3 × 3 filter has 9 weights, however large the image
Tip: Most libraries let you plot the first layer's filters. In a trained network, they almost always look like edge and colour detectors.

In one line

A convolution slides a small learned filter across the image and records how strongly each spot matches its pattern, which is how networks find edges, textures and shapes.

Saved on this device. Sign in to keep progress everywhere.

Share with a friend