Alex Loftus
← Back to the lesson

An image is a point in space

The same four pixels become four coordinates. The highlighted pixel and coordinate refer to the same value.
The same four pixels become four coordinates. The highlighted pixel and coordinate refer to the same value.

How can a picture be one point?

Start with a tiny image: two rows, two columns, four brightness values. Read the top row from left to right, then the bottom row. The image becomes an ordered list:

[1001]⟶x=(1,0,0,1).\begin{bmatrix}1&0\\0&1\end{bmatrix} \quad\longrightarrow\quad x=(1,0,0,1).

Nothing has disappeared. We have changed the arrangement of the numbers, and can fold the list back into the original square. The order matters: every image must use the same reading order.

Four entries, four coordinates

You already know how two coordinates locate one point on a plane. The same idea works with four coordinates, even though we cannot draw all four axes at once. One image is one point; its pixels supply its coordinates.

A grayscale image with 64 rows and 64 columns has 64×64=409664\times64=4096 coordinates. A collection of 100 such images is 100 points in that 4096-dimensional space. Adding images adds points; increasing image resolution adds coordinates.

A collection becomes a matrix

Stack two image vectors as rows:

X=[10010011].X=\begin{bmatrix}1&0&0&1\\0&0&1&1\end{bmatrix}.

Each row is an observation. Each column records the same pixel position across observations. For a color image, include red, green, and blue values in a fixed order: a 64×6464\times64 RGB image has 3×4096=12,2883\times4096=12{,}288 coordinates.

An array can store these values with separate height, width, and channel axes. Those storage axes are distinct from the number of coordinates in the flattened vector.

Check the picture

If we collect 200 images, each with 10 rows and 10 columns, how many points and coordinates do we have?

Answer: 200 points, each with 100 coordinates. A row-per-image data matrix has shape 200×100200\times100.