QuiddityML

A short history of computer vision: from hand-written rules to learning from photos

The four approaches computer vision has moved through, what each could and could not do, and small PyTorch examples of a hand-written rule, a hand-designed measurement and a network that reads pixels.

Computer VisionBy · 27 November 2026 · 7 min read

The history of computer vision is mostly a change in who decides what to look for in an image. The earliest programs ran on rules that people wrote by hand. Later systems had people choose what to measure and let a learning algorithm decide what the measurements meant, and current systems learn both from example photos. Knowing the steps explains why vision models today are trained on huge collections of photos.

The problem every approach has to solve

A computer receives a photo as a grid of numbers, one per pixel (a tiny square of the image) for a grayscale photo, where 0 is black and 255 is white. Suppose you want a program that says whether a photo shows a cat, and you write the rules yourself. You might start with pointed ears, whiskers and fur.

Then a photo arrives of a cat seen from behind, with no whiskers in view. Another shows a cat curled up with its legs tucked in. A cartoon cat has no fur texture at all, and a cat in a dark room is mostly black pixels. Each new photo needs another rule, and the rules start to contradict each other. None of them says how to find an ear in a grid of numbers in the first place.

The rule cat = pointed ears + whiskers + fur fails on four photos: a cat from behind with no whiskers in view and a curled-up cat with legs tucked in. It also fails on a cartoon cat with no fur texture and on a dark photo that is mostly black pixels.

Machine learning takes the other route. You show the system many photos with the right answer attached, and it finds the patterns that separate cats from everything else, including the odd cases. The history below is the path from the first route to the second.

Era one: hand-written rules

The earliest vision programs ran entirely on rules people wrote. One rule might say that an edge is a place where brightness jumps sharply between neighboring pixels. Another might say that a box is four edges meeting at corners.

The edge rule fits in a few lines of PyTorch. It compares each pixel in a row with its right-hand neighbor and reports every spot where the jump is bigger than 50:

import torch

def find_edges(row, jump=50):
    """Hand-written rule: an edge is where brightness jumps sharply between neighbors."""
    jumps = (row[1:] - row[:-1]).abs()
    return (jumps > jump).nonzero().flatten().tolist()

block_on_table = torch.tensor([40, 42, 41, 200, 203, 201, 39, 40])
shadowed_wall = torch.tensor([188, 187, 189, 72, 70, 73])

print(find_edges(block_on_table))
print(find_edges(shadowed_wall))
[2, 5]
[2]

On the row that crosses a bright block on a dark table, the rule finds the block's two sides, between positions 2 and 3 and between 5 and 6. On the second row it also reports an edge at position 2, but that row is a single flat wall with a shadow across part of it. The paint never changes, and the rule has no way to know that.

Rules like these worked in tidy settings, such as a few toy blocks on a plain table under steady light. They broke as soon as the lighting changed, the background got cluttered or objects overlapped.

Top: three clean blocks on a table, where the rules work. Bottom: overlapping boxes, a shadow and scattered stray edge marks, where the rules break.

Era two: hand-designed measurements plus a classifier

The next approach split the job in two. People still decided by hand what to measure in an image, and a learning algorithm decided what those measurements meant.

For example, a program could divide a photo into small squares and count how many edges in each square point in each direction. A standing person tends to produce a pattern with many vertical edges. A simple classifier, a model that picks a label from a fixed list, was then trained on labeled photos and learned which patterns meant "person".

The measurement step looks like this for an 8 by 8 image split into four 4 by 4 squares. For each square it counts vertical edges (jumps between left and right neighbors) and horizontal edges (jumps between upper and lower neighbors):

import torch

def edge_direction_counts(img, cell=4, jump=0.5):
    """Hand-designed measurement: per square, count vertical and horizontal edges."""
    vertical = (img[:, 1:] - img[:, :-1]).abs() > jump    # jump between left and right neighbors
    horizontal = (img[1:, :] - img[:-1, :]).abs() > jump  # jump between upper and lower neighbors
    counts = []
    for r in range(0, img.shape[0], cell):
        for c in range(0, img.shape[1], cell):
            v = vertical[r:r + cell, c:c + cell].sum().item()
            h = horizontal[r:r + cell, c:c + cell].sum().item()
            counts += [v, h]
    return counts

standing = torch.zeros(8, 8)
standing[1:8, 3:5] = 1.0   # a tall, narrow bright shape
lying = standing.T          # the same shape on its side

print(edge_direction_counts(standing))
print(edge_direction_counts(lying))
[3, 1, 3, 1, 4, 0, 4, 0]
[1, 3, 0, 4, 1, 3, 0, 4]

Each pair is (vertical, horizontal) for one square. The tall shape gives mostly vertical counts and the same shape on its side gives mostly horizontal ones. Those eight numbers, not the raw pixels, are what the classifier saw.

A standing person on a grid of squares with short marks showing the edge directions counted in each square, designed by hand, feeding a learned simple classifier that answers person

This beat pure rules, because the classifier learned from examples which counts meant "person". The measurements could only capture what their designers thought to include, though. If the useful clue was something nobody thought to count, the classifier never saw it.

Era three: neural networks that learn from labeled photos

The next approach learns everything from examples, including what to measure. A neural network takes the grid of pixel values directly and adjusts millions of internal numbers until its answers match the right ones. Even the small network below has more than a million of them:

import torch
from torch import nn

# a small network that reads the pixel grid directly and scores 3 labels: cat, dog, car
model = nn.Sequential(
    nn.Flatten(),
    nn.Linear(3 * 64 * 64, 128),
    nn.ReLU(),
    nn.Linear(128, 3),
)

photo = torch.rand(1, 3, 64, 64)   # one 64 by 64 color photo
print(model(photo).shape)
print(f"{sum(p.numel() for p in model.parameters()):,} internal numbers")
torch.Size([1, 3])
1,573,379 internal numbers

The input is the photo itself, 3 color values for each of 64 by 64 pixels, and the output is one score per label. Nothing in between was designed to count edges. Training adjusts the 1.6 million numbers, so whatever the network ends up measuring comes from the photos.

The most direct way to train one is supervised learning. You collect photos, have people label each one with the right answer and train the network to reproduce those labels. A well-trained network then gives sensible answers on photos it never saw during training.

Labeled photos of a cat, a dog and a car train a neural network, which then labels a new cat photo it never saw as cat

This approach became the main one once two things were available: millions of labeled photos and computer chips fast enough to train on them.

Era four: learning without labels

Labeling millions of photos by hand is slow and expensive. Outlining every car pixel by pixel in one street photo takes a person a long time.

So newer models also learn from photos that have no labels. One way is to hide part of a photo and train the model to fill in the hidden part from the rest. Another is to learn from photos paired with the captions people wrote for them online.

A model trained this way on a huge collection of images learns general patterns such as edges, textures and object parts. It can then be adapted to a specific task like spotting cracked welds, with far fewer labeled photos than it would otherwise need.

Top: a dog photo with a hidden square, and the model fills in the hidden part. Middle: a photo of a dog catching a ball paired with its caption. Bottom: a large model adapted with a few labeled welds finds a cracked weld.

What each era could and could not do

Era Who decides what to measure Who decides what it means Weak spot
Hand-written rules people people changed lighting, clutter, overlap
Hand-designed measurements people a classifier clues nobody thought to count
Supervised neural networks the network the network needs many labeled photos
Learning without labels the network the network, then a few labels needs a huge image collection

Common mistakes when reading this history

  • Expecting a rule to survive a new setting. A rule that works on a few blocks under steady light can report edges at every shadow once the lighting changes, as the wall example shows.
  • Thinking a network needs no data work. Supervised training reproduces its labels, so wrong or inconsistent labels get learned too.
  • Assuming no labels means no work. A model trained without labels still needs a few labeled photos to be adapted to a specific task such as spotting cracked welds.
  • Hand-coding a fix for every odd photo. Each new rule tends to break an older one. More varied example photos usually help more than one more rule.

What is computer vision? covers what a vision system receives and the kinds of answer it returns. How images are stored as tensors explains the pixel grids every one of these approaches starts from. For the learning side, what is machine learning and what is a neural network cover the basics in more depth.

QuiddityML teaches these four approaches as one concept in the first unit of its Computer Vision track, where one exercise has learners put the four in order, earliest first (QuiddityML).