How a computer stores a picture or a word
A computer stores a picture as a grid of tiny squares called pixels. Each pixel is saved as numbers: in a color picture, three numbers from 0 to 255 for red, green and blue. A word is saved as one number for each letter. Many AI systems then split words into pieces called tokens.
Last reviewed: 20 October 2026 6 min read
How does a computer store a picture?
A computer stores a picture as a grid of numbers. Each square in the grid is a pixel, and each pixel gets its own number or numbers.
A black-and-white picture.
In a simple gray picture, each pixel is one number: 0 for black, 255 for white, and the numbers between for grays.
Worked example: a smiley in 25 numbers.
Here is a 5-by-5 picture. Read the numbers, and the face appears.
| Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | |
|---|---|---|---|---|---|
| Row 1 | 255 | 255 | 255 | 255 | 255 |
| Row 2 | 255 | 0 | 255 | 0 | 255 |
| Row 3 | 255 | 255 | 255 | 255 | 255 |
| Row 4 | 0 | 255 | 255 | 255 | 0 |
| Row 5 | 255 | 0 | 0 | 0 | 255 |
The two 0s in row 2 are the eyes. Rows 4 and 5 make the smile. The computer stores only the 25 numbers, in order; the face is something you see when they are laid out.
A color picture.
In a color picture, each pixel gets three numbers: how much red, how much green and how much blue light to mix, each from 0 to 255. The web's color standard lists colors this way:
| Color | Red | Green | Blue |
|---|---|---|---|
| Red | 255 | 0 | 0 |
| Yellow | 255 | 255 | 0 |
| Blue | 0 | 0 | 255 |
| White | 255 | 255 | 255 |
| Black | 0 | 0 | 0 |
Yellow surprises most people: on a screen it is red light plus green light.
Why 255?
A computer stores numbers in bits, which are 0s and 1s. Eight bits make one byte, and eight bits can count 256 different values: 0 to 255. So one color number fits in exactly one byte.
How many numbers is one photo?
One example picture in a university course is 248 pixels wide and 400 pixels tall, with three color numbers per pixel: 248 × 400 × 3 = 297,600 numbers. A picture 1,920 pixels wide and 1,080 tall would hold 6,220,800 numbers. Most picture files are saved in a squeezed form, called compression, so the file is smaller than that count, but the computer unpacks it back into pixel numbers to show it.
How does a computer store a word?
A computer stores a word as one number for each character. A shared standard called Unicode "provides a unique number for every character". Every letter, digit, space, punctuation mark and emoji has its own number, so a message typed on one device shows the same letters on another.
Worked example: "cat".
In Unicode, small "c" is 99, "a" is 97 and "t" is 116. So the word "cat" is stored as:
| Letter | c | a | t |
|---|---|---|---|
| Unicode number | 99 | 97 | 116 |
| In bits | 01100011 | 01100001 | 01110100 |
Capital letters have different numbers. Capital "C" is 67 and capital "A" is 65. To a computer, "Cat" and "cat" are different until a program is told to treat them the same.
How many bytes per character?
The most common way to save Unicode text, called UTF-8, stores each basic English letter in a single byte. Other characters take two, three or four bytes. A smiling-face emoji, number 1F600 in Unicode's hexadecimal numbering, takes four bytes.
How does an AI read a word?
Many AI systems that work with text don't read one letter at a time, and they don't read whole words either. They first split text into tokens. A token is often a whole word, but it can also be a common piece of a word, such as "-er".
Worked example from a textbook.
If a system has never seen "lower" but knows "low" and "er", it can split the new word into those two tokens. A very unusual word can fall all the way back to single letters.
The system's list of tokens is its vocabulary, and real vocabularies hold 50,000, 100,000 or even 200,000 tokens. Each token has a position in that list, so the text becomes a row of numbers. Then each number is swapped for a longer list of numbers, called a vector, that the system works with.
So a sentence goes on a journey: letters become Unicode numbers, the text is split into tokens, tokens become position numbers, and position numbers become vectors.
How does an AI see a picture?
An AI that works with pictures receives the same grid of numbers as any other program. A university course on computer vision puts it plainly: to a computer, an image is "one large 3-dimensional array of numbers": width, height and three colors.
The AI never receives "a cat". It receives 297,600 numbers, or however many the picture has, and has to find patterns in them that match what people call a cat.
What does an AI receive, and what does it lose?
Turning the world into numbers always keeps some things and drops others.
| Thing | What the computer receives | What gets lost |
|---|---|---|
| A photo | Pixel numbers for red, green and blue | Everything outside the frame, plus sound, smell, and why the photo was taken |
| A tiny or blurry photo | Fewer pixels | Small details that need more pixels to show |
| A spoken word, typed out | Character numbers, then tokens | Tone of voice, who said it and the moment it was said in |
| The same word with different spelling or capitals | Different numbers | The fact that a person would read them as the same word, unless the program is told |
| Text in a language with fewer tokens | More, smaller pieces for the same sentence | Some efficiency: vocabularies built mostly from English leave fewer tokens for other languages |
Asking "what did the machine receive, and what did it lose?" is a habit worth keeping for any AI system.
Where this sits in the learning path. The learning path the curriculum is built around returns to how machines represent things at every age. The representation strand reads, for ages 8 to 10, "Pictures, words, features, and missing information"; for ages 11 to 13, "Fields, vectors, token/context intuition, shortcuts"; for ages 14 to 15, "Embeddings and representation tradeoffs"; and for ages 16 to 18, "Pipelines, provenance, geometry and failure analysis."
Try it at home: a picture and a name in numbers (no device needed)
You need squared paper, a pencil and about 10 minutes.
- Draw a 5-by-5 grid. Fill some squares black and leave the rest white.
- Write the picture as numbers: 0 for black, 255 for white, row by row.
- Read only the numbers to someone else. Can they draw your picture without seeing it?
- Now write a short word you like, such as a favorite food, in Unicode numbers, using the table below.
- Swap words written as numbers with someone at home and decode each other's.
| a | b | c | d | e | f | g | h | i | j | k | l | m |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 |
| n | o | p | q | r | s | t | u | v | w | x | y | z |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 |
For ages 11 and up: turn your smiley into color by giving each pixel three numbers. How many numbers does your picture need now? (Answer: 75.)
What this guide does and does not show
It shows:
- The basic idea: pictures become grids of pixel numbers, and words become character numbers, then tokens, then vectors.
- Real values from the standards: the web's color numbers and Unicode's letter numbers.
It does not show:
- How compression squeezes picture files, or the other ways of describing color.
- How each AI system splits text. Tokenizers differ, so the same word can split differently in two systems.
- How the vectors are learned. That is a bigger story about training.
Where does Mechna Academy fit?
Mechna Academy is a city of machines for curious children aged 8 to 18, opening first to ages 8 to 10. In each mission, a child guesses how a machine decides, then opens its Peek Hatch to check, changes one thing and tests it on a case it has never seen. Children learn how AI works this way, and they never chat with an AI.
Questions
As a grid of pixels, each saved as numbers. In a color picture each pixel has three numbers from 0 to 255, for red, green and blue light. The picture you see is those numbers laid out in rows.
Each character has its own number in a shared standard called Unicode, so small "c", "a" and "t" are 99, 97 and 116. The computer saves those numbers as bits. Capital letters have different numbers from small ones.
A pixel is one tiny square in the grid that makes up a digital picture. Each pixel is stored as one number in a gray picture, or three numbers in a color picture.
Each color number is stored in one byte, which is eight bits. Eight bits can count 256 different values, from 0 to 255.
Many AI systems split text into tokens, which are whole words or common pieces of words. Each token becomes a number from the system's vocabulary, and then a longer list of numbers called a vector.
Mechna Academy is a city of machines for curious children aged 8 to 18, opening first to ages 8 to 10.
Mechna Academy is a city of machines for curious children aged 8 to 18, opening first to ages 8 to 10.
For grown-ups: join the waitlistPlaces are limited. The waitlist is for parents and guardians 18 and older.