# Pixel Puzzle Pictures and Computational Thinking

Solve simple colour-by-number and logical thinking puzzles and gain a deeper understanding of image representation and compression.

Pixel puzzles turn the ways images are represented as a series of numbers representing pixels into puzzles. They come in various forms from a simple variant of colour-by-numbers to more complex puzzles based on compression where images are represented by fewer numbers so take up less storage – but can you get them back! Each representation needs its own algorithm to follow to get the image back.

Colour the grids or make them from lego, or even use them as needlepoint/tapestry patterns!

• algorithms
• representation of images
• pixels and raster graphics
• compression algorithms
• run length encoding
• data representation
• logical thinking
• computational thinking

Also for younger children practice and explore:

• numeracy
• counting
• colours
• symmetry

Teach as part of:

• computing
• maths
• art
• history

## Simple Colour-by-number Puzzles

The Computing

One way images are represented and so stored in a computer or digital camera is as a grid of numbers. This way of representing an image is called a bitmap image or a raster image.

Each image is split in to a grid of squares. Each number gives the colour of that square of the image. Each square is called a pixel. The more pixels making up the image the higher the resolution it has. Higher-resolution pictures have more detail and in particular lines are smoother. The image is less pixelated – you see the squares less. It also means you can see more fine detail – smaller things may disappear in a low resolution image.

Each image has to also come with (or have pre-agreed) a key indicating which number corresponds to which colour. The number of colours allowed is called the colour depth. The more colours, the more bits are needed to store each pixels colours. With two colours you need a single bit for each pixel, with 4 colours you need 2 bits, with 8 colours you need 3 bits, and so on. Each bit pattern represents a different number and so a different colour.

Computational Thinking

An important part of computational thinking involves being able to choose an appropriate representation of data. It is important to know about different representations already used. Choosing representations is a part of abstraction: choosing what matters to represent about data and what can be ignored. With bitmap images, part of that is in choosing the resolution.  By splitting the image in to small squares and ignoring finer detail, we get an easy way to store, manipulate and transmit images. Once the image is a list of numbers we can explore variations of the representation that allow us to compress the image – store it using fewer numbers.

This is also an example of decomposition with respect to data. The image is decomposed in to small squares. A different way to decompose an image, so a different representation is by the lines and shapes within it. This decomposition instead leads instead to vector images.

Every image is unique, but by choosing a representation of bitmap images we get a generalised way to represent an image. Any image can be represented this way.

Instructions: Simple Colour-by-number Puzzles

Each square holds a number that tells you the colour to colour in that square. Look up the colours in the key.

Explore different algorithms for colouring them in. For example:

1. Work along the rows colouring each pixel in turn before moving to the next row.
2. Pick a colour then work along the rows, colouring pixels of only that colour. When you get to the end of the grid, pick the next colour and start again. Repeat this until you run out of colours.
3. Pick an uncoloured square and colour it, then colour all pixels around it that are the same number, moving outwards until their are no more adjacent pixels with that number. Then pick a new uncoloured square and repeat until the whole picture is done.

Resources: Colour-by-number Puzzles

Here are Colour by Number Pixel Puzzle Picture sheets and solutions that you can download. Here the answers are visible so you can see what the pictures are – or send kids to our “Bit of cs4fn” website where they can download them directly themselves without seeing the answers first.

Mini beasts Pictures

Bees amongst flowers

Bees amongst flowers with many other mini beasts

• Puzzle Sheet: (colour key)[PDF] See also lo res version – puzzle 1 above
• Puzzle Sheet: Simple Colour By Number Pixel Puzzle 3b – mini beasts   (black and white key) [PDF] forthcoming
• Solution Sheet:[PDF]

Halloween Pictures

Christmas and Winter Pictures

There are lots of pixel puzzles linked to Christmas and Winter on our Christmas pixel puzzle page.

## The Romans and Pixel Puzzles

Teach some computing when covering the Romans: mosaics are just pixel pictures. They even realised they could make really detailed (high resolution) images by using small tiles or tesserae. Try our Roman Mosaic Pixel Puzzle or why not make your own Roman mosaic version of a pixel puzzle. Find out more on our Roman Mosaic Computing page including a link to an online mosaic designing site.

## Programming Pixel Puzzles

Pixel puzzles can be turned in to programming puzzles by programming a turtle to paint the picture given the numbers. There are different algorithms for programming it just as humans do them in different ways. The turtle could, for example:

• Run back and forth across the rows colouring each square in turn covering the grid just once OR
• Jump around the grid colouring in the first colour, then jump around the grid colouring in the second colour and so on, …
• The program could use a form of run length encoding  (see below) to save having an instruction in the program for every square.

Can the students come up with different ways, or improve their first version to be a simpler program? Let each come up with a way and then have them share the different ways they did it.

## Sending Colour-by-number Puzzles

The simple colour by number pictures include the numbers on the grid, but what if you want to send a picture to someone else. You just need to record the list of numbers and know the grid size. These puzzles can be combined with activities sending images across the room by e.g. holding up cards one at a time, for the distant person to copy down, for example.

Instructions: Colour-by-number Puzzles

Each line of instructions tells you how to colour the next one or more lines of the picture by giving the number corresponding to the colour of the next pixel.

So, for example with a colour lookup table  1 Blue, 2 Red :  1 1 1 2 2 2 would mean colour three pixels blue and then three pixels red.

Resources: Colour-by-number Puzzles

Here are Colour by Number Pixel Puzzle Picture sheets and solutions that you can download.

African Animal Picture

## Pixel Spreadsheets with real image files

The next step is to explore real images. You can convert actual image files into a spreadsheet, eg holding x,y and R G B numbers for each pixel. You can then change the numbers (eg zeroing all the Green values) and then see what you get.

## Symmetrical Colour-by-number Puzzles

In these symmetrical colour by number pictures you are only given the numbers for half the pixels. Use symmetry to work out the rest of the numbers and so the rest of the picture.

This can also be used as an introduction to the idea of compression – if you know something about the properties of a picture you can reconstruct the image despite storing fewer numbers!

Find out more on our symmetrical pixel puzzle page

## Run length Encoding Puzzles

Instructions: Run length Encoding Puzzles

We give these puzzles in two forms, one slightly harder where everything is numbers and the other easier to follow where the colours are given explicitly. Each pair gives the number of pixels to colour and the colour to use. Colour the pixels following the instructions in order.

Computational Thinking Hint

The way data (here of images) is represented affects the amount of storage needed. Raster graphics involves treating an image as a grid. You then store a number to represent the colour at every point (or pixel) in the grid. Run-length encoding cuts how many numbers you need to store by counting the runs of numbers.

Resources: Run length Encoding Puzzles

Here are some Run length Encoding Pixel Puzzle Picture sheets and solutions that you can download. The version without a colour key is easier to follow so suitable for younger students.

Egypt Picture

## Logical Thinking Compressed Pixel Puzzles

Instructions: Logical Thinking Compressed  Pixel Puzzles

The numbers on each row of a Logical Thinking Compressed Pixel Puzzle tell you the number of cells in each group of black cells in the row. So if the numbers next to a row are 2,4,5 it means that row has a block of 2 black cells, a block of 4 black cells and a block of 5, in that order. Each block is separated by one or more white cells. White cells could also come before or after the blocks. Columns are encoded in the same way.

Computational Thinking Hint

To solve the compressed pixel puzzles you have to use logical thinking, alternating between different rows and columns, applying the new information you deduce about one to the other.

Resources: Logical Thinking Compressed Pixel puzzles

Here are some computer science linked Pixel puzzle sheets and solutions that you can download (more to come):

More Puzzles

Lots more computational thinking puzzles including the cs4fn Computational Thinking Puzzle Book Issue 1

## Odd-even Pixel Puzzles

These colour by number puzzles explore the patterns in odd and even numbers. Find out more on our Odd-even Pixel Puzzle page.

## Multiplication Table Pixel Puzzles

These colour by number puzzles explore how patterns can lead to new algorithms while learning your times tables. Find out more on our including a link to an online mosaic designing site.