Level 0: Images and Tools¶
Level 0 ยท Overview ยท โฑ๏ธ ~3โ4 weeks at about an hour a day ยท Prerequisites: basic Python (variables, loops, functions, lists, and dictionaries)
Level 0 turns "I know some Python" into "I know exactly what's inside an image, and I can load, convert, inspect, resize, annotate, and save images and video without the classic bugs." Every later level, from filters and feature matching to detectors and diffusion models, starts by handling pixels correctly, and that's what you learn here.
What this level covers¶
You start with the big picture: what computer vision is, the main tasks it solves (classification, detection, segmentation, tracking, reconstruction, and generation), how the field evolved from hand-written edge detectors to foundation models, and why seeing is so much harder for a computer than it is for you.
Then you set up the workbench: the Python vision stack of NumPy, OpenCV, Pillow, scikit-image, matplotlib, and PyTorch with torchvision. You learn what each library is for, and above all where they disagree: channel order, dtypes, value ranges, axis layouts, and resize defaults.
Next you go underneath the pixels. You follow light through a camera sensor and its Bayer color filter, simulate demosaicing, and see what sampling, quantization, color spaces (RGB, HSV, Lab, YCbCr), gamma encoding, and compression (PNG, JPEG, WebP, RAW) do to the numbers. Then you learn to manipulate images fluently as arrays: shapes and strides, uint8 overflow, cropping and channels, broadcasting for color math, the HWC and CHW layouts, normalization, and batching for neural networks.
You finish with the everyday mechanics: reading and writing files, the BGR vs RGB trap, displaying images honestly with matplotlib, resizing without distortion, drawing annotations, and processing video frame by frame.
What you'll be able to do¶
- Explain what computer vision is, name the task behind any vision problem, and say why nuisance factors such as lighting and viewpoint make it hard.
- Set up a clean vision environment, and move images between NumPy, OpenCV, Pillow, scikit-image, matplotlib, and PyTorch without silent changes.
- Explain how a camera turns light into numbers, including the Bayer filter, demosaicing, quantization, gamma, and JPEG compression, and predict how each affects a model.
- Convert between color spaces by hand and with OpenCV, and know each library's value ranges.
- Manipulate images as arrays: crop, split and merge channels, do color math with broadcasting, and avoid overflow, view, and layout bugs.
- Prepare correctly normalized CHW batches for a PyTorch model, and undo the preprocessing for display.
- Read, write, resize, annotate, and display images and video correctly, including aspect-preserving resizing and per-frame video analysis.
Chapters¶
| # | Chapter | What it covers | Time |
|---|---|---|---|
| 1 | What is computer vision? | Seeing vs understanding, the main tasks, a short history, applications, why vision is hard, how to study | ~45 min read + 1 h practice |
| 2 | Setting up your vision toolkit | The Python vision stack, what each library is for, their conventions, installing, sample images, notebooks, GPUs | ~45 min read + 1โ2 h practice |
| 3 | Digital images | Sensors and the Bayer filter, sampling and quantization, resolution and bit depth, color spaces, gamma and sRGB, image formats and compression | ~70 min read + 3โ4 h practice |
| 4 | Images as arrays | HWC layout and strides, dtypes and overflow, indexing and channels, broadcasting for color math, HWC vs CHW, normalization, batching | ~60 min read + 3 h practice |
| 5 | Working with images and video | OpenCV and Pillow I/O, the BGR vs RGB trap, displaying with matplotlib, resizing and aspect ratio, drawing, video reading and writing, webcams | ~60 min read + 3 h practice |
How to study this level¶
flowchart LR
R["Read a section"] --> T["Type and run the code"]
T --> L["Look at every image"]
L --> B["Break it on purpose"]
B --> E["Do the exercises"]
E --> C["Check yourself<br/>without notes"]
C --> R
- Type the code; don't paste it. Then change one thing (the image, a parameter, a dtype) and predict the result before you run it.
- Look at every intermediate image. Most vision bugs are visible: blue faces, black holes where bright areas should be, squashed objects. Plot the exact array your code is using, not the one you think it's using.
- Say the shape, dtype, and channel order out loud before every line that touches an image. "This is (480, 640, 3), uint8, BGR." This one habit prevents most Level 0 bugs.
- Keep an "image bugs" log. BGR vs RGB,
uint8wraparound,(x, y)vs(row, col),(w, h)vs(h, w), and HWC vs CHW will each catch you at least once. Write down what happened and how you noticed. - Use the OpenCV and image I/O cheat sheet while you practice, and the ML Handbook's NumPy chapter if arrays and broadcasting are new to you.
If you already use OpenCV
Skim chapters 1 and 2 and do their exercises. Don't skip chapters 3 and 4, even if you've loaded thousands of images: knowing what gamma, chroma subsampling, strides, and normalization do to your numbers is what separates "it usually works" from "I know why it works", and later levels assume it.
Capstone¶
The level ends with a project: build a photo-processing tool, a command-line script that batch-converts, resizes, captions, and watermarks a folder of images, writes a contact sheet, and reports per-image statistics (size, mean color, brightness, and sharpness) to a CSV file. Finish it without notes before you start Level 1: Image processing.