Phase 04: Computer Vision

Image Fundamentals — Pixels, Channels, Color Spaces

An image is a tensor of light samples. Every vision model you will ever use starts from this one fact. Explain how a continuous scene gets discretized into pixels and why sampling/quantization decisions set the ceiling on every downstream model. Read, slice, and inspect images as NumPy arrays and switch fluently between HWC and CHW layouts. Convert between RGB, grayscale, HSV, and YCbCr and justify why each color space exists. Apply pixel-level preprocessing (normalize, standardize, resize, channel-first) exactly as pretrained PyTorch vision models expect it. Every paper you will read, every pretrained weight you will download, every vision API you will call assumes a specific encoding of the input. Pass a uint8 image where the model wants float32 and it will still run — and silently produce garbage. Feed BGR to a network trained on RGB and accuracy collapses by ten points. Hand a model channels-last input when it expects channels-first and the first conv layer treats height as a feature channel. None of this throws an error. It just ruins your metrics and you spend a week hunting for a bug that lives in how you loaded the file. A convolution is not complicated once you know what it is sliding over. The hard part is that "an image" means different things to a camera, a JPEG decoder, PIL,…

Image Fundamentals — Pixels, Channels, Color Spaces: An image is a tensor of light samples. Every vision model you will ever use starts from this one fact.

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.