Model NITI Aayog, 24-27 Dec, online. Write an original white paper.

How Does a Computer Recognise What Is in a Picture? | How It Works

12 min read

On this page

What is the short answer?

To a computer, a photo is a grid of numbers. Each pixel holds brightness values for red, green and blue, and nothing in the grid says "cat" or "bicycle".

A convolutional neural network turns those numbers into a label in stages. Small filters slide across the image and respond to simple patterns such as edges. Later layers combine them into larger patterns, and a final layer scores every label the network knows.

Nobody writes the filters by hand. The network sets them during training, adjusting its numbers until it labels example photos correctly, and is then tested on new photos. Even strong networks err on unusual photos, and their training data can carry bias.

Definition: Image classification, in the words of Stanford University's CS231n course, is "the task of assigning an input image one label from a fixed set of categories".

How does a computer turn a picture into numbers?

Stanford's CS231n notes say a computer represents an image as "one large 3-dimensional array of numbers". Each number is a whole number from 0 (black) to 255 (white). A colour image has three colour channels, red, green and blue.

The notes' example is a cat photo 248 pixels wide and 400 pixels tall. It holds 248 × 400 × 3 = 297,600 numbers.

The notes list why the task is hard. One object can appear from many viewpoints and at many sizes. It can bend, be partly hidden (occlusion), sit in poor light or blend into a busy background. Each change alters many pixel values while the label stays the same.

The notes say it is not obvious how to write an algorithm that spots cats. Instead they describe a data-driven approach: give the computer many labelled examples of each class, and let a learning algorithm work out what each class looks like.

How do small filters pick out edges and textures?

A filter is a small grid of numbers called weights; CS231n gives 5 × 5 × 3 as a typical first-layer size. The filter slides across the image. At each position, its weights are multiplied by the pixel values beneath, and the products are added. This step is convolution, and the grid of results is an activation map.

A large result means the patch matches the filter's pattern. According to CS231n, first-layer filters come to respond to "an edge of some orientation or a blotch of some color", and higher layers to "honeycomb or wheel-like patterns".

A ReLU layer replaces every negative number with zero. A pooling layer shrinks each map, often keeping the largest value in each 2 × 2 block. A final fully connected layer gives one score per class. Every position is checked with the same filter, which CS231n calls parameter sharing; this keeps the number of weights small.

How does a network learn from labelled examples?

Training starts with a training set of images that people have already labelled. A loss function measures how far the network's scores are from the right labels; CS231n says it lets people "quantify the quality" of any set of weights. The goal is the weights with the lowest loss.

The usual method is gradient descent. Using the chain rule, a step called backpropagation works out how each weight affects the loss. Every weight is nudged in the direction that lowers it, and the cycle repeats. The notes say a typical batch holds 256 examples from a training set of 1.2 million.

A network can fit its training images closely yet fail on new ones, which is overfitting. So a validation set, which CS231n calls "a fake test set", is used to tune settings. A test set then shows how well the network generalises to unseen images. The notes advise using it "only a single time, at the very end".

How did convolutional networks go from reading digits to ImageNet?

CS231n dates the first successful convolutional networks to the 1990s, when Yann LeCun's LeNet read zip codes and digits.

The University of Toronto notes that ImageNet, developed by Stanford professor Fei-Fei Li, arrived in 2009, larger than any earlier image dataset "by several orders of magnitude". Its yearly challenge (ILSVRC), held from 2010, set a classification task of 1,000 classes; from 2012, it had about 1.2 million training images and 100,000 test images.

Each image carries one label, though it may show several objects, such as a photo labelled "strawberry" that also holds an apple. So a network may give five guesses and counts as right if one matches. The share of misses is the top-5 error.

In 2012, Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton of the University of Toronto in Canada entered a network later named AlexNet, with 60 million parameters and five convolutional layers, trained on graphics processing units. On the 2012 test set, with no external training data, its top-5 error was 16.4%, against 26.2% for the next team, the organisers reported in 2015.

In 2014, Karen Simonyan and Andrew Zisserman of the University of Oxford in the United Kingdom showed that stacking very small 3 × 3 filters, 16 to 19 weight layers deep, brought a significant improvement.

Why does a trained network make mistakes?

In their 2015 paper, the ILSVRC organisers studied the 2014 winning network's mistakes on 1,500 test images.

It struggled with very small or thin objects, with photos altered by filters that change colour and contrast, and with objects shown in abstract form, such as paintings, sketches or statues. The authors wrote that they believe humans are "significantly more robust" to abstract forms.

In December 2019, MIT News reported on ObjectNet, a test set of 50,000 photos of objects tipped on their side, shot at odd angles and placed in cluttered rooms. Leading models' accuracy fell from as high as 97% on ImageNet to 50 to 55% on ObjectNet.

Some errors are caused on purpose. In December 2013, Christian Szegedy and six co-authors reported that an "imperceptible perturbation" can make a network misclassify an image; they termed such images adversarial examples. The National Institute of Standards and Technology (NIST), a United States agency, wrote in January 2024 that defences against such attacks are "incomplete at best".

How can training data build bias into a network?

A network learns only from what its training images show. In a 2019 paper, Kaiyu Yang and four co-authors, among them Fei-Fei Li, examined the "person" categories of ImageNet. They wrote that a dataset's data and label distributions "are critical to the models' behavior", and noted reports of "lower performance for underrepresented groups".

Where photos come from matters too. The International Institute of Information Technology, Hyderabad, an institute in India, says on its India Driving Dataset (IDD) page that earlier driving datasets tended to focus on "structured driving environments", with clear lanes and drivers who follow traffic rules. IDD holds about 10,000 images from 182 drive sequences on Indian roads, labelled with 34 classes.

Do these networks recognise objects the way people do?

Researchers disagree; the question is unsettled.

One group of researchers argues that deep networks share something with primate vision. In December 2014, MIT News reported a study led by Charles Cadieu and James DiCarlo of MIT, a university in the United States.

The team compared neuron recordings from monkeys' visual areas with networks' internal patterns, and found that one network "matches the primate brain" at recognising objects in a brief glance. MIT News added that such networks model only the brain's "feedforward" paths.

Another group argues that networks often rely on different clues. In a 2019 conference paper, Robert Geirhos and colleagues at the University of Tübingen, a university in Germany, showed networks images in which a cat's outline was filled with elephant skin.

They found that networks trained on ImageNet were "strongly biased towards recognising textures rather than shapes", unlike human observers. A standard network labelled their example image "Indian elephant".

How does this work with real numbers?

Both examples use illustrative numbers, except where CS231n is named.

How does a filter find an edge in a tiny image?

Take an illustrative 3 × 3 patch where a dark area meets a bright one, and a 3 × 3 vertical-edge filter.

Table: Illustrative edge patch and filter

RowPatchFilterProducts added
120, 20, 220-1, 0, 1-20 + 0 + 220 = 200
220, 20, 220-1, 0, 1-20 + 0 + 220 = 200
320, 20, 220-1, 0, 1-20 + 0 + 220 = 200

Adding all nine products gives 200 + 200 + 200 = 600, a large output.

An illustrative flat patch, with rows 100, 102, 101; 99, 100, 100; and 101, 100, 102, gives 1 per row, so 3 in all: near zero. Flip the edge, bright side left, and the output is -600, which ReLU turns into 0.

How many numbers does one layer learn?

Take an illustrative layer of 32 filters, each 3 × 3 pixels across 3 colour channels. Each filter has 3 × 3 × 3 = 27 weights, so the layer has 32 × 27 = 864 weights. With one bias per filter, it learns 864 + 32 = 896 numbers.

Shared filters keep this count fixed for any photo size. One fully connected unit linked to every number in CS231n's cat photo would need 297,600 weights, about 332 times as many (297,600 ÷ 896 ≈ 332). CS231n's real example, AlexNet's first layer, has 96 filters of 11 × 11 × 3: 34,848 weights, or 34,944 with biases.

Where can the student go deeper in World 101?

The World 101 subject Signal & Image Processing takes the wider view of the mathematics that cleans up and makes sense of sound, light and sensor readings, from a blurred photo to a noisy heartbeat trace, and of the careers that use it, such as computer vision engineering.

Three related subjects go further. The Math Behind Machine Learning covers the gradients, the chain rule and step-by-step optimisation behind a falling loss. Artificial Intelligence & the Mind asks whether a machine that labels things well is doing anything like human thinking or perception. Neuroscience looks at how the brain works, including how brain cells build what people see.

Sources

  • Stanford University, CS231n: Deep Learning for Computer Vision, course notes on classification, optimisation and convolutional networks, Spring 2026 edition, read 18 November 2026 (LeNet, 1990s).
  • A. Krizhevsky, I. Sutskever and G. E. Hinton, NeurIPS 2012, abstract page.
  • O. Russakovsky and others, "ImageNet Large Scale Visual Recognition Challenge", arXiv:1409.0575, September 2014, revised January 2015 (challenge run since 2010).
  • University of Toronto, Arts & Science news, 21 March 2025 (AlexNet; ImageNet, 2009).
  • K. Simonyan and A. Zisserman, University of Oxford, arXiv:1409.1556, September 2014, revised April 2015.
  • C. Szegedy and others, arXiv:1312.6199, December 2013, revised February 2014.
  • NIST, news release, 4 January 2024.
  • K. Martineau, MIT News, 10 December 2019 (ObjectNet).
  • K. Yang and others, arXiv:1912.07726, 16 December 2019.
  • IIIT Hyderabad, India Driving Dataset page, read 18 November 2026.
  • A. Trafton, MIT News, 18 December 2014.
  • R. Geirhos and others, University of Tübingen, arXiv:1811.12231, November 2018 (ICLR 2019).

Common errors and misconceptions

  • Misconception: A computer takes in a photo the way a person does. Correct: It receives a grid of numbers, 0 to 255 per colour channel in CS231n's description, and computes scores from them.
  • Misconception: Programmers write the rules for spotting each object. Correct: The network learns its filter weights from labelled examples by lowering a loss.
  • Misconception: A network that does well on its training images will do well on any photo. Correct: Only unseen test images show how it generalises; on ObjectNet, leading models fell to 50 to 55% accuracy.
  • Misconception: AlexNet's 16.4% top-5 error means its first guess was right 83.6% of the time. Correct: Top-5 counts a hit if any of five guesses matches, so first-guess accuracy is lower.
  • Misconception: Researchers agree that these networks recognise objects as people do. Correct: An MIT team found one network matched the primate brain in a brief glance; a Tübingen team found networks lean on texture, unlike people.

Key takeaways

  • To a computer, a colour photo is a grid of numbers: three values per pixel, each from 0 to 255 in CS231n's description.
  • Small filters slide across the image, multiplying and adding pixel values; large outputs mark patterns such as edges, and later layers build larger patterns.
  • Training lowers a loss on labelled images through backpropagation and gradient descent; a separate test set, used once, shows how well the network generalises.
  • ImageNet's yearly challenge from 2010 offered about 1.2 million labelled training images; in 2012, AlexNet's top-5 error was 16.4%, against 26.2% for the next team.
  • Networks make more errors on small objects, abstract forms and odd angles, and images with tiny deliberate changes, called adversarial examples, can be misclassified.
  • Training data can build in bias, and researchers disagree over how closely these networks match the way people recognise objects.

Test yourself

How many numbers describe CS231n's 248 × 400 colour photo?

248 × 400 × 3 = 297,600 numbers, since each pixel has a red, a green and a blue value.

In the worked example, why does the edge patch give 600 but the flat patch only 3?

The filter subtracts the left column from the right; a big jump in brightness gives a big result, while nearly equal values cancel.

What does the loss function do during training?

It measures how far the network's scores are from the correct labels, and training adjusts the weights to make it smaller.

Why may a network give five guesses in the ImageNet challenge?

Each image has one label but may show several objects, so a network counts as right if any of five guesses matches.

What did the ObjectNet test show?

Leading models' accuracy fell from as high as 97% on ImageNet to 50 to 55% on photos of objects at odd angles.

What did Geirhos and colleagues find about networks trained on ImageNet?

They were strongly biased towards textures rather than shapes, so a cat outline filled with elephant skin was labelled an elephant.

Curious Computing: how computers, code and the internet work.

Go deeper in World 101: Signal & Image Processing

Write about it

Turn a question from this chapter into a paper.

The Writing Studio has a structure guide, a rubric and citation tools for 15 formats, from essays to research papers. A free account keeps up to five drafts. Learnacy Essential adds feedback from an AI writing coach and submission to The OYI Review.

Publication depends on review and is not guaranteed.