CNNs: how AI looks at images

A convolutional neural network (CNN) is a neural network built for images. Instead of looking at every pixel separately, it slides small filters across the picture to spot local patterns such as edges, corners and textures, then combines them into bigger shapes and finally whole objects.

Everyday analogy

Checking a long property document with a magnifying glass. You move the glass across the page bit by bit, noting stamps, signatures and dates, then put the clues together to decide whether the document is genuine.

Example

Reading a scanned claim form: a CNN finds where the stamp, the signature and the handwritten amount are, and checks the scan is clear enough before the text is read.

Why not use a normal neural network?

A 1000 × 1000 colour photo is 3 million numbers. Connecting every number to every neuron would need billions of weights, and the network would ignore which pixels sit next to each other. A CNN reuses the same small filter everywhere (weight sharing) and keeps neighbouring pixels together, so it needs far fewer weights and learns much faster.

The building blocks

PartWhat it does
ConvolutionSlides a small filter (e.g. 3 × 3) over the image, multiplying and adding at each position
Filter (kernel)A small grid of learned weights. Each filter learns one pattern: a vertical edge, a curve, a texture
Feature mapThe result of one filter: a map of where its pattern appears. Many filters give many maps
StrideHow many pixels the filter jumps each time. A stride of 2 roughly halves the size
PaddingA border of zeros around the image, so the edges aren't lost and the size can stay the same
PoolingShrinks each map by keeping the biggest value (max pooling) or the average of each small patch
Fully connected layerAt the end, combines all the features found to decide the answer
Worked example: one filter on one patch
Image patch        Filter (finds vertical edges)
10  10  0          1  0  -1
10  10  0          1  0  -1
10  10  0          1  0  -1

Each row: 10×1 + 10×0 + 0×(−1) = 10
Three rows: 10 + 10 + 10 = 30  → a strong edge here

Max pooling on a 2×2 patch:  [1 3]
                              [2 5]  → keep 5
IMAGEPixels in
→
CONVOLUTION + ReLUFilters find edges and textures
→
POOLINGShrink, keep the strong signals
→
REPEATDeeper layers find shapes, then parts
→
FULLY CONNECTEDDecide: "cat", "dent", "stamp"

What CNNs are used for

JobWhat it gives youExample
Image classificationOne label for the whole image"This X-ray shows pneumonia" or "no pneumonia"
Object detectionA box and label around every objectFinding cars and pedestrians (e.g. YOLO, Faster R-CNN)
SegmentationA label for every pixelOutlining a tumour; separating road from pavement
Feature extractionA list of numbers that describes the imageImage search: "find photos like this one"

Famous CNNs that moved the field forward

ModelYearWhat it showed
LeNet-51998CNNs can read handwritten digits, e.g. on bank cheques
AlexNet2012Deep CNNs trained on GPUs, with ReLU and dropout, beat older methods by a wide margin
VGG2014Going deeper with many small 3 × 3 filters works well
ResNet2015Skip connections let networks with 100+ layers train without the signal fading

Transfer learning: don't start from zero

Training a CNN from scratch needs millions of labelled images. Transfer learning takes a model already trained on a huge collection (such as ImageNet, with over a million photos in 1,000 categories) and reuses what it learned about edges, shapes and textures.

ApproachHowBest when
Feature extractionFreeze the pretrained layers and train only a new final layerYou have little data and a similar task
Fine-tuningAlso retrain some top layers, gently, with a low learning rateYou have more data or images that look different

Example: with only about 2,000 labelled photos of damaged and undamaged cars, a pretrained CNN can be adapted to sort motor-claim photos, something that would need far more data from scratch. See also Fine-tuning. Newer vision transformers now compete with CNNs, but CNNs remain fast and widely used, especially on phones and cameras.

Try it yourself

About 10 min

Look inside a real CNN

  1. Open CNN Explainer (free, runs in your browser).
  2. Pick an example image and click on the layers one by one.
  3. Click a single neuron to see the filter sliding over the image.

What you should see: Early layers light up on edges and colours; later layers respond to bigger parts, until the last layer gives a probability for each class.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot) where needed. Never paste private or confidential information.

Build it for real · guided projectTeach a neural network to read handwritingAbout 60 min · Copy-paste code · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.