HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Text, Sound and Images in Binary
  1. 1Text and character sets
  2. 2Sound: sample rate and sample resolution
  3. 3Images: resolution and colour depth
  1. Computer Science
  2. /Text, Sound and Images in Binary
  3. /Images: resolution and colour depth

Course 1.2·Lesson 3 of 3

Images: resolution and colour depth

A digital image is a grid of tiny dots called pixels, and each pixel's colour is stored in binary. You learn what the resolution and the colour depth of an image are, how they change its quality and size, and how to work out the size of an image.

about 25 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Text, Sound and Images in Binary
  1. 1Text and character sets
  2. 2Sound: sample rate and sample resolution
  3. 3Images: resolution and colour depth

Try the code and the simulations beside the lesson.

A grid of pixels

Look very closely at a phone screen and you can see that the picture is made of tiny squares of colour. Each square is a pixel, which is short for picture element. An image stored this way is a series of pixels. The colour of each pixel is a binary number, so the whole image is converted to binary, which the computer processes.

On the left, an 8 by 8 grid of pixels showing a simple fir tree in black on white. On the right, the eight rows of the image as 8-bit binary numbers, one for each row, with 1 for black and 0 for white: 00010000, 00111000, 01111100, 11111110, 00111000, 01111100, 11111110 and 00010000.

The picture shows a small image of 8 by 8 pixels with only two colours. Each pixel needs just 1 bit: 1 for black and 0 for white. Each row of the image is one byte. The image needs 8×8=648 \times 8 = 648×8=64 bits.

Resolution

The resolution of an image is the number of pixels in it. We usually give it as width by height, such as 800 by 600, which is 800×600=480000800 \times 600 = 480000800×600=480000 pixels.

  • A higher resolution has more pixels, so it can show finer detail. The image looks sharper, especially when it is made bigger.
  • But every pixel must be stored, so the file is larger.

Colour depth

The colour depth is the number of bits used to represent the colour of each pixel.

  • With ddd bits each pixel can have 2d2^d2d different colours.
  • 1 bit gives 2 colours, 2 bits give 4, 8 bits give 256, and 24 bits give 224=167772162^{24} = 16777216224=16777216 colours.
  • A higher colour depth shows more shades, so colours look more natural and smooth.
  • But each pixel needs more bits, so the file is larger.

Both settings work the same way: as the resolution and the colour depth increase, the quality and the file size of the image both increase.

The size of an image file

Every pixel needs (colour depth) bits.

bits=width in pixels×height in pixels×colour depth\displaystyle \text{bits} = \text{width in pixels} \times \text{height in pixels} \times \text{colour depth}bits=width in pixels×height in pixels×colour depth

An image of 100 by 50 pixels with a colour depth of 8 bits needs 100×50×8=40000100 \times 50 \times 8 = 40000100×50×8=40000 bits, which is 40000÷8=500040000 \div 8 = 500040000÷8=5000 bytes.

What if you double both the width and the height? There are four times as many pixels, so the file is four times as large.

Practise with new numbers

Try it in Python

The program stores a tiny two-colour image as rows of bits and prints it with blocks. Then it works out the size for several colour depths.

Read it first. Then run it. Can you see the shape?

1. Change one 0 to a 1 in a row. Run it again and find the pixel that changed.

2. Add 24 to the list of depths. How many times bigger is that file than the 1-bit one?

Common mistakes

  • Adding the width and the height. The number of pixels is width times height.
  • Colours and bits. 8 bits give 28=2562^8 = 25628=256 colours, not 8 or 16 colours.
  • Forgetting to divide by 8 when the question asks for bytes.
  • Thinking resolution means the size on screen. Here it means the number of pixels.

Remember these

  • An image is a grid of pixels. Each pixel's colour is stored in binary.
  • Resolution: the number of pixels in the image.
  • Colour depth: the number of bits per pixel. ddd bits give 2d2^d2d colours.
  • Higher resolution or colour depth: better quality and a larger file.
  • Bits === width ×\times× height ×\times× colour depth.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. What is meant by the colour depth of an image?
  1. How many colours can a pixel have with a colour depth of 4 bits?
  1. An image is 60 pixels wide and 40 pixels high, with a colour depth of 2 bits. How many bits does it need?
  1. The colour depth of an image goes up from 8 bits to 16 bits. The resolution stays the same. What happens to the file size?
  1. Why might a website use a lower resolution for its pictures?

Enroll free in Text, Sound and Images in Binary

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (4)

An app icon is 32 pixels wide and 32 pixels high, with a colour depth of 8 bits…Easy · High School (9–10) · by StemPy Lab
A photo for a school badge is 640 pixels wide and 480 pixels high…Medium · High School (9–10) · by StemPy Lab
A scanner makes a picture of a page that is 100 pixels wide and 80 pixels high…Medium · High School (9–10) · by StemPy Lab
That was the last lessonBack to the course: take the test
← Text, Sound and Images in Binary
← Sound: sample rate and sample resolutionNext →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

A photo is 200 pixels wide and 150 pixels high, with a colour depth of 16 bits…Hard · High School (9–10) · by StemPy Lab

Python Labs (1)

Sizes of sound and image filesPython Lab · by StemPy Lab

Question Sets (1)

Text, Sound and Images: Concept Check10 questions · by StemPy Lab

Notes (1)

Text, Sound and Images: Quick RevisionNote · by StemPy Lab