Run Length Encoding
Run Length Encoding
Lesson 1 activities
Activity 4.1.1
Extension
Imagine that an image contains:
1,024 pixels (a grid of 32 pixels by 32 pixels)
255 different colours (represented by 8 bits)
The image has been encoded using RLE, producing 116 binary codes comprising 8
bits (to represent the 255 colours) and 5 bits (to represent the colour run length).
Using this information, calculate the following.
AAAABBBBBBBBBCADDDDEEFFFFFFFF
ABCABCABCABCABCABCABCABCABCS
BBGGYYAACCFFEEBBGGYYAACCFFEE
Why is this?
Activity 4.2.1
Implement the RLE compression algorithm in Python.
Test out your program using these data strings:
o AAAABBBBBBBBBCADDDDEEFFFFFFFF
o ABCABCABCABCABCABCABCABCABCS
o BBGGYYAACCFFEEBBGGYYAACCFFEE