Back to 课程

Computer Science GCES AQA

0% Complete
0/0 Steps
  1. Representing Algorithms Aqa
    4 主题
  2. Efficiency Of Algorithms Aqa
    1 主题
  3. Searching Algorithms Aqa
    3 主题
  4. Sorting Algorithms Aqa
    3 主题
  5. Data Types Aqa
    1 主题
  6. Programming Concepts Aqa
    5 主题
  7. Arithmetic Relational And Boolean Operations Aqa
    1 主题
  8. Data Structures Aqa
    3 主题
  9. String Manipulation Aqa
    1 主题
  10. Random Number Generation Aqa
    1 主题
  11. Structured Programming Aqa
    2 主题
  12. Robust And Secure Programming Aqa
    4 主题
  13. Number Bases Aqa
    2 主题
  14. Converting Between Number Bases Aqa
    3 主题
  15. Units Of Information Aqa
    9 主题
  16. Hardware And Software Aqa
    4 主题
  17. Boolean Logic Aqa
    3 主题
  18. Programming Languages And Translators Aqa
    2 主题
  19. Cpu Architecture Performance And Embedded Systems Aqa
    4 主题
  20. Memory Aqa
    2 主题
  21. Secondary Storage Aqa
    3 主题
  22. Fundamentals Of Computer Networks Aqa
    8 主题
  23. Fundamentals Of Cyber Security Aqa
    1 主题
  24. Methods Of Preventing Cyber Security Threats Aqa
    1 主题
  25. Relational Databases Aqa
    2 主题
  26. Ethical Legal And Environmental Impacts Aqa
    2 主题
课 Progress
0% Complete

Exam code:8525

Run Length Encoding

What is run-length encoding?

  • Run-length encoding (RLE) is a form of data compression that condenses identical elements into a single value with a count

Text files

  • For a text file containing the string “AAAABBBCCDAA“, the plain RLE encoding would be “4A3B2C1D2A

  • The string has:

    • four ‘A’s (4A)

    • three ‘B’s (3B)

    • two ‘C’s (2C)

    • one ‘D’ (1D)

    • two ‘A’s (2A)

  • To represent this in binary, the count is stored in a fixed size binary format (e.g. 7 or 8 bits)

  • The character is stored using its ASCII (opens in a new tab) value (7 bits)

  • The binary RLE representation of 4A would be 0000100 1000001

    • 000 0100 – binary for the count (4)

    • 100 0001 – binary for ‘A’ (65)

Images

  • In bitmap images, RLE is used to compress sequences of the same colour

  • For example, a line in an image with 5 red pixels followed by 3 blue pixels could be represented as “5R3B

  • The image has:

    • 5 red pixels (5R)

    • 3 blue pixels (3B)

  • To represent this in binary, the pixel count is stored in a fixed size binary format (e.g. 1, 4, 8 or 16 bits)

  • The colour is stored based on the required colour depth (opens in a new tab) of the image

  • For this example we will assume a colour depth of 2 bits

    • 00 – Black

    • 01 – Red

    • 10 – Green

    • 11 – Blue

  • The binary representation of 5R3B would be 0101 01 0011 11

    • 0101 – pixel count (5), 01 – red

    • 0011 – pixel count (3), 11 – blue

Examiner Tips and Tricks

In the exam, the count and value/colour can be reversed, e.g.

  • A4 instead of 4A (four A’s)

  • R5 instead of 5R (five red pixels)

Make sure you read the question carefully!

Represent Data in Frequency / Data Pairs

How do you represent data in frequency/data pairs?

  • Run-length encoding (RLE) uses frequency/data pairs to compress bitmap image data

  • For example, the following bitmap image with a colour depth of 1 bit would have the following binary bit pattern

Bitmap

Bit pattern

rle
rle-bits
  • Using RLE we group pixel colours and can create frequency/data pairs as follows

    • 30, 11, 20, 11, 20, 11, 50, 11, 30, 11, 10, 11, 60, 11……

rle-groups
  • 3 x 0 = 3 x white, 1 x 1 = 1 x black

  • Data pairs can carry over on to the next line, e.g. end of first line and start of second line is 5 x 0 (5 x white)

How do you represent a bitmap image from frequency/data pairs?

  • To recreate a simple bitmap from frequency/data pairs you need to know what binary code is assigned to what colour and reverse the process above

  • If we assume 0 = white and 1 = black and have the following frequency/data pairs and the image size is 5×3 pixels

    • 20, 11, 30, 31, 10, 51

  • The bitmap image would be

rle-example

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注