TactivergeLite

Lite / Intelligent Robotic Systems / Week 24

Images are arrays of numbers

To a robot, your face is a grid of about two million numbers. Which number is your nose?

About 35 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

Every vision algorithm, from a barcode reader to a self-driving car, starts by treating a picture as a table of numbers. Once you see it that way, image processing becomes arithmetic on arrays: the same skills you used on sensor logs.

Predict

How many bytes does one uncompressed 640 × 480 colour image take with 8 bits per channel?

  1. About 300 kB
  2. About 920 kB
  3. About 7 MB
Guess first, then reveal

640 × 480 = 307,200 pixels × 3 channels × 1 byte = 921,600 bytes ≈ 920 kB. At 30 frames a second that is about 27 MB every second, which is why cameras compress and robots crop.

Discover

Choose the Bright square, then the Gradient. Click pixels to read their values: where is (row 1, column 1)? Which way do column numbers grow? Find the darkest and brightest pixel in the Noisy bar and explain why its 'flat' regions aren't flat.

What the interactive shows (text version)

The pixel diagram shows an 8 × 8 image as a grid of numbered squares. The Bright square image has value 200 in the central 4 × 4 block and 40 elsewhere; the Gradient rises by 30 per column from 20 to 230; the Noisy bar has a brighter band in columns 4 and 5 with random variation of up to ±45 and one bright speck.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch for how a colour image is stored as separate red, green and blue values per pixel, and how many bits each one gets.

How a camera image becomes rows of numbers, including how colour is stored, before any vision algorithm touches it.

“Digital Images - Computerphile” by Computerphile (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

A grid of samples

A camera sensor is an array of light-measuring cells. Each one integrates light during the exposure and is converted to a number: the image is sampled in space (pixels) and quantised in brightness (usually 8 bits, 0–255). A greyscale image is a 2D array img[row][col]; row 0 is at the top.

Colour is three arrays

A colour image stores three channels, red, green and blue, so each pixel is a triple like (230, 40, 35) for a red-ish part. Many cameras actually measure one colour per cell through a mosaic of filters and fill in the other two by interpolation.

Size and cost

Memory = width × height × channels × bytes per channel. Processing time grows the same way, so robots often shrink images (downsample), convert to greyscale, or process only a region of interest. Downsampling an image is sampling again, so fine stripes can alias into false patterns, called moiré.

Same lessons as sensors

Each pixel is a sensor reading with noise, bias (a dark offset), limited range (saturated white areas lose detail) and resolution. Everything from weeks 19–23 applies, now in two dimensions.

Explain it another way

Intuitive

An image is like a mosaic of tiny tiles, each painted one shade from black to white. Write the shade number on every tile and you have what the computer sees.

Technical

A W × H image with C channels of b bits is a W·H·C array of integers in [0, 2ᵇ − 1]. Libraries such as NumPy index it img[y, x, c] with y down the rows.

Mathematical

Pixel pitch p and lens focal length f set the angle each pixel sees: about p/f radians. A 3 µm pixel behind a 4 mm lens sees about 0.75 mrad, or 0.75 mm at 1 m.

Applied

Industrial inspection cameras are often monochrome because a single channel at higher resolution, with controlled lighting, measures edges more precisely than colour would.

Worked example 1

A greyscale camera is 1280 × 720 at 8 bits, 60 fps. What is the raw data rate?

1280 × 720 = 921,600 bytes per frame; × 60 = 55.3 MB/s. That is why the robot crops to the 200 × 200 region it actually needs (2.4 MB/s).

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

bytes

bytes

Practice 3. In img[row][col] with row 0 at the top, which pixel is img[2][5]?
Practice 4. A bright window shows as a block of pixels all exactly 255. What does that tell you?

mV

Apply it

Load a small greyscale photo in Python as a 2D list or array. Print its size, the brightest and darkest values and their positions, then crop the central quarter and save its mean brightness. Explain in one sentence what that mean would tell a robot.

Reflect

Which of the sensor ideas from weeks 19–23 do you think matters most for cameras, and why?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Spikes, median filters and filtering inside a controllerThresholding: from picture to mask →