1.2.30

Converting Binary and Images

Test yourself

Converting Binary and Images

All images are stored as binary. It's important to be able to convert between an image and its binary representation.

Illustrative background for Binary to imageIllustrative background for Binary to image ?? "content

Binary to image

  • In a black and white image, each pixel is represented by 1 bit:
    • A 0 will represent a black area.
    • A 1 will represent a white area.
  • The image will be represented by a binary string. Use the value of each bit to colour each pixel in the right colour.
  • The binary string starts at the top-left of the image, and represents the first row, followed by the second row, and continues until the end of the image.
Illustrative background for Image to binaryIllustrative background for Image to binary ?? "content

Image to binary

  • Each pixel of the image will be represented by one bit of the binary string.
  • Starting at the top left, and working across the first row:
    • Write a 0 if the pixel is black.
    • Write a 1 if the pixel is white.
  • Continue this process until the end of the image.

Jump to other topics

1Computer Systems

1.1Systems Architecture

1.2Memory & Storage

1.3Computer Networks, Connections & Protocols

1.4Network Security

1.5Systems Software

1.6Ethical, Legal, Cultural & Environmental Concern

2Computational Thinking, Algorithms and Programming

2.1Algorithms

2.2Programming Fundamentals

2.3Producing Robust Programs

2.4Boolean Logic

2.5Programming Languages & IDEs

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson