Computer Vision
Pixels, colour, histograms, filters, edges, thresholds, morphology, shapes, geometry, matching, features, CNNs and detection, all computed in plain Python.
- Level
- Intermediate
- Time
- About 24 hours
- Modules
- 5
- Lessons
- 15
- Exercises
- 45
Computer vision teaches computers to make sense of images: to clean them up, find edges and objects, measure and match shapes, and finally recognise what a picture shows. This course builds the field from its foundation, an image as a grid of numbers, through the classic toolkit of filters, thresholds, morphology and geometric transforms, to the ideas behind modern systems: features, convolutional networks, object detection and segmentation.
Everything runs as plain Python in your browser, on images small enough to check by hand, so every pixel of every step is visible. Real libraries such as OpenCV, Pillow and PyTorch cannot run on this site; each lesson shows what the same step looks like in them, as text, so you can use them confidently on your own computer.
What you will learn
- Represent greyscale and colour images as grids and convert between colour spaces
- Adjust contrast with histograms and filter images with kernels
- Find edges, threshold images and clean masks with morphology
- Label objects and measure their size, position and outline
- Resize, rotate and warp images, and match templates and corners
- Classify images with features, explain CNNs, and score detection and segmentation
Skills you will gain
- Pixel-level image processing
- Convolution and filtering
- Segmentation and shape analysis
- Geometric transforms and matching
- Image classification and detection metrics
Before you start
- Python: lists, nested loops, functions and comprehensions (the Python course)
- Comfort with coordinates, averages and simple algebra
- Helpful but not required: the NumPy course, and the Deep Learning course for the last module
Where it is used
- Document scanning and text extraction
- Industrial inspection and counting
- Medical image analysis
- Photo editing and augmented reality
- Self-driving and robot perception
Modules
Module 1: Images as data
Pixels, grids and coordinates, colour channels and colour spaces, and histograms for judging and fixing contrast.
- 1
Pixels, grids and coordinates Intermediate
An image is a grid of numbers. Learn how pixels, rows, columns and brightness values work, how to read, crop, flip and invert an image in plain Python, and how to print one as text shading.
- 2
Colour channels, colour spaces and greyscale Intermediate
A colour image stores three numbers per pixel. Split images into red, green and blue channels, convert colour to greyscale the way cameras and libraries do, and use the HSV colour space to find pixels of a chosen colour.
- 3
Histograms and contrast Intermediate
A histogram counts how many pixels have each brightness. Read histograms to judge exposure and contrast, stretch a dull image to the full range, and spread its levels evenly with histogram equalisation.
Module 2: Filtering
Convolution with kernels and padding, blurring and noise removal with mean, Gaussian and median filters, and edge detection with Sobel gradients.
- 1
Convolution and kernels Intermediate
Slide a small grid of weights over an image and add up the products: that one operation blurs, sharpens and finds edges. Learn kernels, output sizes, borders and padding, and the difference between correlation and true convolution.
- 2
Blurring and noise removal Intermediate
Real images are noisy. Compare the mean, Gaussian and median filters, see why the median removes salt-and-pepper noise without smearing it, and build a separable Gaussian blur from its formula.
- 3
Edges with Sobel gradients Intermediate
Edges are where brightness changes quickly. Measure that change with the Sobel kernels, combine it into a gradient magnitude and direction, and thin thick edges the way the Canny detector does.
Module 3: Finding shapes
Thresholding with Otsu's method and adaptive thresholds, morphology to clean masks, and connected components to count, measure and outline objects.
- 1
Thresholding and Otsu's method Intermediate
Thresholding splits an image into foreground and background. Apply global and inverse thresholds, let Otsu's method choose the threshold from the histogram, and use adaptive thresholds when the lighting is uneven.
- 2
Morphology: erosion, dilation, opening and closing Intermediate
Clean up binary masks by growing and shrinking shapes. Apply erosion and dilation with a structuring element, combine them into opening and closing to remove specks and fill holes, and extend the idea to greyscale images with the top-hat transform.
- 3
Connected components and contours Intermediate
Turn a mask into separate objects. Label connected regions with flood fill, compare 4- and 8-connectivity, measure each object's area, bounding box and centroid, and find its boundary pixels, the idea behind contours.
Module 4: Geometry and matching
Resizing with nearest-neighbour and bilinear interpolation, affine transforms and image warping, and template matching and corner detection.
- 1
Resizing and interpolation Intermediate
Change an image's size by working out, for every new pixel, where it falls in the old image. Compare nearest-neighbour and bilinear interpolation, line up pixel centres correctly, and avoid aliasing when shrinking.
- 2
Affine transforms: shift, scale, rotate and warp Intermediate
Move, scale, rotate and shear images with one 2 × 3 matrix. Compose transforms by multiplying matrices, rotate about a centre, invert a transform, and warp images by backward mapping so no output pixel is left empty.
- 3
Template matching and corner features Intermediate
Find a small pattern inside an image by sliding it and scoring each position with SSD or normalised cross-correlation, then find corners, the distinctive points that feature matching is built on, with the Harris detector.
Module 5: Learning to see
Classifying images with features and nearest neighbours, convolutional neural networks, and detection and segmentation with IoU, NMS and average precision.
- 1
Classifying images with features and nearest neighbours Intermediate
Teach a program to name what is in a picture. Treat images as vectors, classify them with k-nearest neighbours, see why raw pixels fail when objects move, and build HOG-style features from gradient orientations that make classification robust.
- 2
Convolutional neural networks for images Advanced
Let the network learn its own kernels. Follow an image through convolution layers with many channels, ReLU and max pooling to a classifier, compute output shapes and parameter counts, and see why weight sharing and pooling suit images.
- 3
Object detection metrics and segmentation Advanced
Go from "what is in the image" to "where is it". Measure box overlap with IoU, remove duplicate detections with non-maximum suppression, score a detector with precision, recall and average precision, and evaluate segmentation masks with IoU and Dice.
Projects
- An object counter for a factory camera Build a plain-Python pipeline that takes small greyscale images of parts on a conveyor belt, with uneven lighting and noise, and reports how many parts there are, where they are and whether any are too small.
- A shape recogniser with features and a tiny CNN Recognise simple shapes (bars, crosses, squares, triangles and circles) drawn at different positions and sizes in small images, first with hand-made features and nearest neighbours, then with a small convolutional network.
What to learn next
- Deep Learning Neurons, backpropagation, optimizers, normalization, CNNs, RNNs, embeddings, attention and transformers, every network built from scratch in Python.
- Machine Learning Machine learning from scratch in plain Python: regression, gradient descent, regularization, k-NN, logistic regression, metrics, trees, ensembles and k-means.
- NumPy NumPy arrays from the inside: dtypes, indexing, views, masks, broadcasting, reductions, reshaping, statistics, linear algebra, random numbers and images.
- Natural Language Processing Tokenizing, regular expressions, TF-IDF and search, Naive Bayes, sentiment, language models, HMM tagging, entities, spelling, embeddings, BPE and attention in Python.
- Python Programming From your first print() to classes, recursion and data structures.