Skip to content

VisionImages as Numbers

Pixels and Image Size

An image is a grid of pixels; a color pixel stores three numbers, so a 640 × 480 color frame is 921,600 bytes.

Not started Jump to practice

To a robot, a picture is not a scene. It is a big table of numbers.

Key idea

An image is a grid of pixels, $w$ wide and $h$ tall. A grayscale pixel is one number, usually 0 (black) to 255 (white), one byte. A color pixel stores three: red, green and blue. So a color frame takes $w \times h \times 3$ bytes.

Why it works

Knowing the size of an image tells you what a small computer can handle. A 640 × 480 color frame is 921,600 bytes; at 30 frames a second, that is about 28 MB every second. Robots shrink images, turn them gray, or look at only part of them to keep up.

Worked example: Frame size

A 320 × 240 color image.
  1. $320 \times 240 = 76{,}800$ pixels.
  2. $\times 3 = 230{,}400$ bytes.

Answer: 230,400 bytes.

Common mistake

Forgetting the three color channels, or mixing up bits and bytes (8 bits make 1 byte).

Hands-on: see the numbers

Camera setups (approximate U.S. prices, 2026)
  • \$0: your computer's webcam with free Python image libraries.
  • About \$25 to \$35: a Raspberry Pi camera module for a Raspberry Pi you already have.
  • About \$60 to \$90: a small smart-camera board that finds colors and tags itself and sends results to a microcontroller.

Load a photo in Python and print the three numbers of one pixel on a red apple and one on a leaf. Which number is biggest in each?

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading