On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

CS Thinking · Computational Thinking · Grade 6-8

Image Representation

Image representation is the way a computer stores a picture as numeric data.

file size≈width×height×bits per pixel

Quick Answer

Image representation is the way a computer stores a picture as numeric data. Most images are a grid of pixels, and each pixel stores numbers for its color, often red, green and blue values from 0 to 255, which is 3 bytes per pixel. Use it to work out file sizes (width × height × bits per pixel), to explain why zooming in shows squares, and to see what a lower resolution or compression throws away.

Why This Matters

Knowing how images are stored explains everyday puzzles: why a 4000 × 3000 phone photo would take 36 MB before compression, why a small icon looks blocky when stretched, why a black-and-white drawing can be far smaller than a photo, and why editing one pixel means changing three numbers. It also lets you predict how a change in resolution or color depth changes the file size.

Intuitive Explanation

Take a sheet of graph paper and fill every square with one color. From across the room it looks like a picture; up close it is just squares. A digital image is the same: a grid of pixels, each with a single color. An image 8 pixels wide and 8 tall has 64 pixels. If each pixel is only black or white, one bit per pixel is enough (1 for black, 0 for white), so the whole image takes 64 bits, which is 8 bytes.

Color needs more numbers. Screens mix red, green and blue light, so each pixel stores three values, usually 0 to 255 each, one byte per color. (255, 0, 0) is bright red, (0, 0, 0) is black, (255, 255, 255) is white, and (255, 255, 0) is yellow, because red and green light together look yellow. That is 3 bytes, or 24 bits, per pixel. The file size follows directly: a 100 × 100 color image is 10,000 pixels × 3 bytes = 30,000 bytes before compression.

Two ideas are easy to mix up. Resolution is how many pixels the image has; display size is how big it is drawn on a screen. Stretch a 100 × 100 picture across a whole wall and it still has 10,000 pixels, each drawn as a bigger square, which is why it looks blocky. The file format is a separate choice again: a PNG and a JPEG of the same 100 × 100 picture hold the same number of pixels but encode them differently, so their file sizes differ.

Think of it like this. A digital image is a mosaic of tiny tiles, each one a single solid color. The whole picture lives in the list of tile colors and positions, and if you zoom in far enough you see the tiles. Unlike a real mosaic, the computer stores no tiles at all, only numbers: three for each tile, for red, green and blue.

Core idea. Image quality depends on how many pixels there are and how much color information each pixel stores.


When to Use

Use image representation when a question involves pixels, resolution, color values such as RGB, or the size of an image file. Typical tasks: work out how many bytes an image needs, decode a small grid of bits into a picture, or explain why an enlarged image looks blocky. If the question is how to make the file smaller, that is Data Compression. If it is about representing data in general (text, sound), that is Data Representation.

Tip. Ask: Is a picture being stored or measured as a grid of pixels with color values?

How to Recognize It

Check whether the numbers in front of you describe a picture: a width and height in pixels, and how each pixel's color is stored.

  1. Are you given a width and height in pixels, like 1920 by 1080?

    Yes points to image representation; multiply them to count the pixels. If you are given samples per second instead, it is Audio Representation.

  2. Is each pixel's color stored as numbers, such as three values from 0 to 255?

    Yes is image representation. If the question is about how text or numbers in general become bits, it is the wider Data Representation.

  3. Is the file size worked out as pixels times bits per pixel, with nothing removed?

    Yes is the raw image size. If a format like JPEG or PNG is shrinking that size by finding repeats or dropping detail, it is Data Compression.

  4. Does changing the number of pixels, or the bits per pixel, change the answer?

    Yes keeps you at image representation. If only the size shown on screen changes, the stored data is the same and so is the file size.

Image Representation vs Data Representation vs Data Compression vs Audio Representation

These four all turn real things into bits, so the words overlap. Ask what is being stored, pictures or sound or anything at all, and whether you are describing the raw data or shrinking it.

Image Representation

Meaning
Image representation stores a picture as a grid of pixels, each with numbers for its color.
Key test
Width, height and bits per pixel decide the answer.
Formula
bits=w×h×bits per pixel
Example
A 10 by 10 icon in 24-bit color holds 100×24=2,400 bits, which is 300 bytes.

Data Representation

Meaning
Data representation covers every way of turning information, including text, numbers, sound and pictures, into bits.
Key test
The question is about encoding in general, not pixels in particular.
Formula
E:D→{0,1}∗
Example
Storing the word 'Hi' as the ASCII codes 72 and 105.

Data Compression

Meaning
Data compression stores the same information in fewer bits, sometimes dropping detail to save more.
Key test
The file gets smaller while the pixel grid stays the same size.
Formula
ratio=original sizecompressed size
Example
A 6 MB photo saved as a 1.5 MB JPEG has a compression ratio of 4.

Audio Representation

Meaning
Audio representation stores sound as a list of measurements of the sound wave, taken many times each second.
Key test
Samples per second and bits per sample take the place of width and height.
Formula
bits per second=rate×depth×channels
Example
One second of mono sound at 8,000 samples per second and 8 bits each holds 64,000 bits.

Formula & Notation

file size≈width×height×bits per pixel
A raster image is a function from pixel coordinates (x,y) to color values. Storage size depends on the number of pixels and the number of bits used for each pixel's color data.

Worked Examples

Example 1 — Decode a 1-bit icon

Easy

A 5 × 5 black-and-white icon is stored with 1 bit per pixel, 1 = black and 0 = white, row by row: 00100 01110 11111 01110 00100. Describe the picture, and say how many bits and whole bytes it uses.
Show the steps and the answer
  1. Cut the bits into 5 rows of 5, since the image is 5 pixels wide.

    The width tells you where each row of pixels ends.

  2. Shade each 1: row 1 has its middle pixel black, row 2 the middle three, row 3 all five, row 4 the middle three, row 5 the middle one.

    With 1 bit per pixel, each bit is one square: 1 for black, 0 for white.

  3. Read the shape: the black part grows from 1 pixel to 5 and shrinks back to 1, a diamond.

    Looking at the rows together turns the numbers back into a picture.

  4. Count the storage: 5 × 5 = 25 pixels × 1 bit = 25 bits, which needs 4 whole bytes (32 bits).

    Files are stored in whole bytes, and 3 bytes (24 bits) would be one bit short.

Answer: A black diamond on a white background; 25 bits, stored in 4 bytes.

Takeaway: The width tells you how to cut the bits into rows, and the bits per pixel tell you how many bits each square uses.

Example 2 — Stretching adds no pixels

Standard

A 200 × 150 color photo uses 24 bits per pixel. It is shown at normal size, then stretched to 4 times the width and 4 times the height. How many pixels does it have before and after stretching, and how many bytes is its uncompressed data? How much would a real 800 × 600 photo need?
Show the steps and the answer
  1. Count the pixels: 200 × 150 = 30,000.

    Resolution is fixed by the image data, not by the screen.

  2. Work out the size: 30,000 pixels × 3 bytes = 90,000 bytes, about 90 KB uncompressed.

    24 bits per pixel is 3 bytes, one each for red, green and blue.

  3. Stretch it 4 times wider and taller: still 30,000 pixels, each drawn as a 4 × 4 block of screen dots.

    Showing an image bigger repeats the pixels it already has instead of creating new detail, which is why it looks blocky.

  4. A real 800 × 600 photo: 480,000 pixels × 3 bytes = 1,440,000 bytes.

    4 times the width and 4 times the height make 4 × 4 = 16 times the pixels, and 16 times the data.

Answer: 30,000 pixels and 90,000 bytes, both before and after stretching. A real 800 × 600 photo has 480,000 pixels and needs 1,440,000 bytes, 16 times as much.

Takeaway: Displayed size and resolution are different: only more pixels add detail, and more pixels cost more bytes.

Example 3 — Find the mistake: forgetting color depth

Application

A 1,000 × 1,000 image uses 24-bit color. Nia works out its size: "1,000 × 1,000 = 1,000,000 pixels, so the file is 1,000,000 bytes, about 1 MB." Find the mistake and correct it. How big would the image be in 8-bit grayscale?
Show the steps and the answer
  1. Find what Nia left out: she counted the pixels but treated each one as a single byte.

    File size depends on both how many pixels there are and how many bits each one uses.

  2. Use the color depth: 24 bits per pixel = 24 ÷ 8 = 3 bytes.

    That is one byte each for red, green and blue.

  3. Recompute: 1,000,000 pixels × 3 bytes = 3,000,000 bytes, about 3 MB.

    Each pixel stores three numbers, so the data is three times what Nia wrote.

  4. In 8-bit grayscale: 1,000,000 pixels × 1 byte = 1,000,000 bytes, about 1 MB.

    Nia's number fits only a one-byte-per-pixel image, such as one with 256 shades of gray.

Answer: About 3 MB (3,000,000 bytes) uncompressed. Nia's 1 MB is the size of the 8-bit grayscale version.

Takeaway: Size = width × height × bits per pixel; always include the color depth.

Where You'll See It

  • Zooming into a photo until you see squares

    Pinch-zoom far enough and the picture breaks into colored squares — each square is a pixel storing red, green, and blue values, proving the image is really a grid of numbers.

  • Why a phone photo is a big file

    A 4000-by-3000 photo has 12 million pixels, and each stores about 3 bytes of color — multiplying width x height x bits-per-pixel is why high-resolution photos eat so much storage.

  • Pixel art in a game

    Old-school game sprites are drawn on a small grid where you set each cell's color by hand — that grid of color values is exactly how every digital image is stored, just smaller.

Common Mistakes

  1. The slip: An image that looks bigger on screen has more pixels.

    Why it's tempting: Bigger usually means 'more' in everyday life, so a larger display seems to imply more data.

    Instead: Displayed size and pixel count are different: the same pixels can be stretched larger (each pixel just drawn bigger). Pixel count (resolution) is fixed by the image data, not by how big you show it.

  2. The slip: Resolution and file format are the same thing, so two files of the same size hold the same image.

    Why it's tempting: Both relate to 'image quality,' so they blur together.

    Instead: Resolution is how many pixels there are; the format (and its compression) decides how those pixels are encoded. A JPEG and a PNG of the same scene can differ greatly in file size at identical resolution.

  3. The slip: Changing a black-and-white image to full color keeps the file the same size, since it has the same number of pixels.

    Why it's tempting: The width and height have not changed, so the amount of data seems unchanged too.

    Instead: Size is pixels × bits per pixel. An 8 × 8 image takes 64 bits at 1 bit per pixel, but 64 × 24 = 1,536 bits (192 bytes) in 24-bit color, 24 times as much before compression.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. A black-and-white icon is 8 × 8 pixels with 1 bit per pixel. How big is it in bits and in bytes?

    Hint: Multiply width × height × bits per pixel. 8 bits make a byte.

  2. An image is 100 × 50 pixels in 24-bit RGB colour. What is its uncompressed size in bytes?

    Hint: 24 bits is 3 bytes per pixel.

  3. How many different colours can one pixel show with 8 bits per pixel? With 24 bits per pixel?

    Hint: n bits give 2n different patterns.

  4. A photo is 1920 × 1080 pixels with 24-bit colour. About how many megabytes is it uncompressed? Use 1 MB = 1,000,000 bytes.

    Hint: Count the pixels first, then use 3 bytes per pixel.

  5. A photo file shrinks from 6 MB to 1 MB when saved as JPEG, but it is still 1920 × 1080 pixels. Did the image's resolution change, or is this data compression?

    Hint: Look at what stayed the same: the pixel grid.

  6. A student zooms a 64 × 64 icon to fill the whole screen and says: 'Now it has many more pixels, so it's higher quality.' Correct them.

    Hint: Does zooming add any new stored colour values?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Why does a photo get blurry or blocky when I make it bigger?

Because enlarging a photo adds no new information. The computer has to invent the extra pixels by copying or blending the ones it has, so each original pixel turns into a small blob or block. TV scenes where someone zooms into a security camera and reads a number plate are fiction: if the plate covered 10 pixels, there are only 10 pixels of detail. Newer AI tools can guess at missing detail, but they are guessing, not recovering it.

How can 3 numbers make millions of colors?

Each of red, green and blue can be any whole number from 0 to 255, which is 256 choices each. Mixing them gives 256×256×256=16,777,216256 \times 256 \times 256 = 16{,}777{,}216 colors, about 16.7 million. Red 255, green 255 and blue 0 gives yellow, because screens mix light rather than paint. Equal amounts of all three give a gray, from black at 0 to white at 255.

Are all images stored as pixels?

No. Vector images, such as SVG files and most fonts and logos, store shapes instead: 'a circle at this point with this radius, filled blue'. The computer draws the shapes fresh at whatever size you need, so a vector logo stays sharp on a phone and on a billboard. Photos stay as pixels, because a real scene has far too much detail to describe as shapes.

Learning Path

Image Representation

You are here

You need Data Representation (bits mean something only under a rule) and Binary (reading bit patterns as numbers) first. Image Representation applies those ideas to pictures: a grid of pixels, a color depth in bits per pixel, and file size = width × height × bits per pixel. Next, Data Compression shows how formats like PNG and JPEG store the same pixels in far fewer bytes.

See Also