Study Guide

Representing Images

How a computer stores a picture as a grid of pixels, each coded in binary, and how the resolution and the colour depth change the quality and the size of an image.

Lesson 1.8 Data Representation

For: Cambridge IGCSE Computer Science learners, or anyone who can already convert between binary and denary

Stage: Think

A picture over the phone

A fictional pupil, Aroha, has a small picture made by colouring squares black on squared paper. Her friend Ben has a blank sheet of the same squared paper, and they can only talk on the phone.

Think it through

How could Aroha describe the picture so that Ben can colour in exactly the same squares? What would she need to tell him first, and then for every square?

Show a model answer

She tells Ben how many squares wide and how many tall the picture is. Then she goes through it in order, row by row from the top, saying for each square whether it is black or white. Because there are only two possibilities, she could say 1 for black and 0 for white, which is exactly the kind of information a computer can store.

A computer stores a picture in the same way. The picture is divided into a grid of tiny squares called pixels (short for picture elements). Each pixel is one single colour, and the code for that colour is stored in binary. The computer stores the grid’s size, then the code of every pixel, row by row.

Stage: Discover

Encoding a black-and-white picture

A small picture of a house is 8 pixels wide and 6 pixels tall. Each pixel is either black or white.

Think it through

If each pixel is stored as a single bit, how many pixels are in the picture, and how many bits will the whole picture take?

Show what happens

The picture has 8 × 6 = 48 pixels, and with one bit for each pixel it takes 48 bits, which is 6 bytes.

Here is the picture, written with # for a black pixel and . for a white one. Let 1 stand for black and 0 for white. Write each row as 8 bits.

The house, row by row
RowPicture (# black, . white)8-bit binary
1...##...0001 1000
2..####..
3.######.
4########
5.######.
6.##..##.

    Show the completed table
    RowPicture (# black, . white)8-bit binary
    1...##...0001 1000
    2..####..0011 1100
    3.######.0111 1110
    4########1111 1111
    5.######.0111 1110
    6.##..##.0110 0110

    The six rows take 6 × 8 = 48 bits, as you predicted. Notice that this is a table of bits only: the computer also needs to know that each row is 8 pixels wide, so that it can start a new row in the right place.

    Check your understanding

    One row of a black-and-white picture is stored as 1001 1001, where 1 is black and 0 is white. Which row of the picture is it?
    Show the answer

    Answer: B. #..##..# (black, two white, two black, two white, black)

    Reading from the left, 1 0 0 1 1 0 0 1 is black, white, white, black, black, white, white, black.

    Stage: Predict

    How many pixels?

    The same house can be drawn on a grid that is 8 pixels wide and 6 tall, or on one that is 16 pixels wide and 12 tall.

    Think it through

    The grid is doubled in width and in height, from 8 × 6 to 16 × 12. How many pixels does it have now? Which picture will have smoother edges, and which will need more bits?

    Show what happens

    The first grid has 48 pixels and the second has 16 × 12 = 192, which is four times as many, not twice: both the width and the height doubled. The bigger grid has smaller pixels, so edges look smoother, and with one bit for each pixel it needs 192 bits, four times as many bits.

    The number of pixels in an image is its resolution. It can be given as the width by the height (such as 16 × 12), or as the total number of pixels (192). A higher resolution means more, smaller pixels, so more detail and a smoother picture, but also more data to store.

    Counting pixels
    WidthHeightNumber of pixels
    4416
    86
    2010
    10050
    1000500

      Show the completed table
      WidthHeightNumber of pixels
      4416
      8648
      2010200
      100505000
      1000500500 000

      Stage: Predict

      More than black and white

      Aroha now wants to draw a house in four colours: white, black, red and blue. One bit for each pixel is not enough.

      Think it through

      How many bits does each pixel need if the picture uses four different colours? Make up a code of that many bits for each colour.

      Show what happens

      2 bits make 2² = 4 patterns, so each pixel needs 2 bits. One possible code is 00 for white, 01 for black, 10 for red and 11 for blue. It could be any other, as long as the sender and the receiver use the same one.

      The number of bits used for the colour of each pixel is the colour depth. A colour depth of n bits gives 2ⁿ different colours.

      Colour depth and number of colours
      Colour depthNumber of colours
      1 bit2
      2 bits
      3 bits
      8 bits
      24 bits

        Show the completed table
        Colour depthNumber of colours
        1 bit2
        2 bits4
        3 bits8
        8 bits256
        24 bits16 777 216

        Using the code 00 white, 01 black, 10 red and 11 blue, a row of 6 pixels is black, red, red, blue, white, black.

        A row of six pixels with a 2-bit colour depth
        PixelColour2-bit code
        1black01
        2red
        310
        4blue
        500
        6black

          Show the completed table
          PixelColour2-bit code
          1black01
          2red10
          3red10
          4blue11
          5white00
          6black01

          The row is stored as 01 10 10 11 00 01: 12 bits for 6 pixels, which is 6 × 2.

          Check your understanding

          A fictional club logo uses five different colours. What is the smallest colour depth that can store it?
          Show the answer

          Answer: C. 3 bits, because 2³ = 8 and that is at least five colours.

          2² = 4 is too few, and 2³ = 8 is enough, so the smallest colour depth is 3 bits. Three of the eight patterns are left unused.

          Stage: Explain

          Two settings that get mixed up

          Think it through

          One fictional photo looks blocky: you can see square steps along every edge. Another has smooth edges, but its sky is made of a few flat bands of blue instead of a smooth change. For each photo, say which setting is too low, the number of pixels or the number of bits for each pixel.

          Show a model answer

          The blocky photo has too few pixels: its resolution is too low, so each pixel is large. The photo with bands of blue has too few colours to choose from: its colour depth is too low, so a smooth change has to be rounded to a few steps.

          Do not confuse: Resolution and colour depth

          How many pixels?Image resolution
          The number of pixels in the image, such as 16 × 12 = 192.A higher resolution gives smaller pixels and a sharper picture.
          How many bits for each pixel?Colour depth
          The number of bits used for the colour of each pixel, which sets how many colours are possible.A higher colour depth gives more colours and smoother changes of colour.

          Raising either one improves the quality of the image and makes the file bigger.

          The number of pixels and the number of colours are separate. A picture with a very high resolution can still use only two colours, if each pixel has 1 bit. A picture with only a few pixels can have millions of colours, if each pixel has 24 bits. Resolution says how many pixels; colour depth says how many colours each pixel can be.

          Each version is worked out as pixels × bits for each pixel.

          1. Black and white, 8 × 6. 48 pixels × 1 bit = 48 bits.
          2. Black and white, 16 × 12. 192 pixels × 1 bit = 192 bits: four times as many, because there are four times as many pixels.
          3. Four colours, 8 × 6. 48 pixels × 2 bits = 96 bits: twice as many, because each pixel has twice as many bits.
          4. Four colours, 16 × 12. 192 pixels × 2 bits = 384 bits: eight times the first version, since it has four times the pixels and twice the bits.

          Each increase improves the picture and enlarges the file. The next lesson turns this working into a rule.

          Stage: Apply

          Choose settings for a job

          Apply it

          A fictional pupil prints a school poster from a small photo, and the printed picture shows large square blocks along its edges. Which change would help most, and what is the cost?
          Show the answer

          Answer: B. Use a photo with a higher resolution, at the cost of a bigger file.

          The blocks are the pixels, so the photo needs more of them: a higher resolution. The cost is a bigger file.

          Apply it

          A fictional sunset photo has plenty of pixels, but the sky shows clear bands of orange instead of a smooth change. Which setting is most likely too low?
          Show the answer

          Answer: A. The colour depth, because too few colours are available for a smooth change.

          Bands show that colours are missing, not pixels. The colour depth is too low, so a smooth change is rounded to a few steps.

          Apply it

          Two fictional pictures are stored. Picture P is 100 × 100 pixels with 8 bits for each pixel. Picture Q is 50 × 50 pixels with 24 bits for each pixel. Which needs more bits, and why?
          Show the answer

          Answer: C. Picture P, because 100 × 100 × 8 = 80 000 bits and 50 × 50 × 24 = 60 000 bits.

          P: 10 000 pixels × 8 bits = 80 000 bits. Q: 2500 pixels × 24 bits = 60 000 bits. Both settings matter, and neither one alone decides the size.

          Go deeper Beyond the specification: file headers and vector graphics

          An image file is not only a list of pixel codes. A bitmap file starts with a file header that stores information such as the image’s width, its height and its colour depth, so that a program knows how to read the pixels that follow. The image’s resolution is a property of the file. It is different from the screen resolution, which is the number of pixels a display can show.

          A bitmap image stores a code for every pixel. A vector graphic stores shapes instead: a drawing list of drawing objects, each with properties such as its position, size and colour. A tiny example, not a real file format:

          rectangle  x=10  y=10  width=80  height=40  fill=blue
          circle     x=50  y=30  radius=15           fill=yellow

          Because the shapes are described, a vector graphic can be drawn at any size without blocky edges, and the list can be short for a simple logo. A photograph has too much detail to describe in shapes, so it is stored as a bitmap. The specification for IGCSE asks only for bitmap images.

          Stage: Consolidate

          Bring it together

          Think it through

          Without looking back, explain to a friend how a computer stores a picture, and what image resolution and colour depth each mean.

          Show a model answer

          The picture is a grid of pixels. Each pixel is one colour, stored as a binary code, and the codes are stored row by row. The resolution is the number of pixels (width × height). The colour depth is the number of bits used for each pixel’s colour, so n bits give 2ⁿ colours.

          Check your understanding

          An image has a colour depth of 4 bits. How many different colours can each pixel be?
          Show the answer

          Answer: A. 16, because 2⁴ = 16.

          2 × 2 × 2 × 2 = 16 colours.

          • A computer stores an image as a grid of pixels. Each pixel has one colour, stored as a binary code, and the codes are kept row by row.
          • The image resolution is the number of pixels, written as width × height. Doubling both width and height gives four times as many pixels.
          • The colour depth is the number of bits for the colour of each pixel. With n bits there are 2ⁿ colours: 1 bit gives 2, 8 bits give 256 and 24 bits give 16 777 216.
          • A higher resolution and a higher colour depth both improve quality and make the file bigger. They are separate settings: more pixels do not mean more colours.
          • Blocky edges point to too low a resolution. Flat bands of colour point to too low a colour depth.

          Sources and scope

          • What this lesson is. The eighth lesson of the Data Representation module, written for this site. It teaches point 3 of Cambridge IGCSE Computer Science 1.2 (images, resolution and colour depth) against the 2026 to 2028 syllabus (version 6). Its curriculum links are provisional: no link has been verified by the site owner. They show where the lesson may help with a course and imply no review or endorsement by any examination board.
          • Original material. Aroha and Ben, the pixel house, the four-colour code, the club logo, the poster, the sunset photo and the two stored pictures are fictional examples written for this lesson. The colour codes are made up to practise decoding, and are not a real standard.
          • Simplified on purpose. Colours are treated as codes in a list; how a 24-bit colour is made from red, green and blue is not taught. The calculation of a file size, in bytes and larger units, is in the next lesson. File headers, vector graphics and screen resolution appear only in the optional extension.