Images as data

Pixels, grids and coordinates, colour channels and colour spaces, and histograms for judging and fixing contrast.

About 4 hours of study

Learning objectives

Lessons

  1. 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. 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. 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 practice

Module quiz

1. How many values does an 8-bit greyscale pixel allow?
2. In image coordinates, which way does y grow?
3. Which colour looks brightest to people at the same channel value?
4. A dull image uses only levels 90 to 150. Which fix spreads it over 0 to 255 without changing the histogram's shape?
5. Why is HSV better than RGB for selecting a coloured object?
6. Equalisation maps level v to round((cdf(v) - cdf_min) x 255 / (N - cdf_min)). What happens to a level shared by many pixels?

Filtering ›