CSP - Mobile 3.3 Representing Images
CSP - Mobile 3.3 Representing Images
RLE Introduction
How can computers store pictures when they can only use binary numbers? How can we
compress images so that they are faster to transmit and easier to store? Screens and images are
divided up into a grid of small dots called pixels (picture elements). The letter “a” has been
magnified below to show the pixels. When a computer stores a picture, all that it needs to store is
which dots are black and which are white.
1, 3, 1
4, 1
1, 4
0, 1, 3 ,1
0, 1, 3, 1
1, 4
The picture above shows us how a picture can be represented by numbers using Run Length
Encoding (RLE) used in fax machines. The first line consists of one white pixel, then three
black, then one white pixel, represented as 1, 3, 1. The first number always relates to the
number of white pixels. If the first pixel is black, the line will begin with a zero.
RLE Exercises
1. Try drawing in the following RLE compression and see if you get something you
recognize. Remember the first number in each row is the number of white pixels.
0, 6
4, 1, 1
3, 1, 2
2, 1, 3
1, 1, 4
0, 6
Mobile CSP | Student Lesson
Unit 3 | Image Representation
Course Listing: http://course.mobilecsp.org
To color the cell, select the cell(s), then set the background color:
2. Create your own black and white picture(for example, the first letter of your first/last name or
a number) and then write down the RLE encoding for it.
Fill in the RLE numbers for each row below (remember to start with the number of white pixels
(0 if there are none) and alternate)
------------------------------------------------------------------------------------------------------------------------------
Run-Length Encoding: N
Row 1: __0,1,4,1_________________
Row 2: ___0,2,3,1_______________
Row 3:___0,1,1,1, 2,1_________________
Row 4:__0,1,2,1,1,1__________________
Row 5:___0,1,3,2_________________
Row 6:__0,1,4,1__________________
Mobile CSP | Student Lesson
Unit 3 | Image Representation
Course Listing: http://course.mobilecsp.org
Fill in the color codes and the RLE numbers for each row below. Use an initial number to
represent the color (for example 0 for white, 1 for black, 2 for red or diagonally shaded) before
you write down the number of pixels of that color. For example, 0, 4, 2, 3 means white 4 pixels
followed by red 3 pixels in that row.
-------------------------------------------------------------------------------------------------------------------------------
Run-Length Encoding: Circle
Hint: You will need to convert from binary to decimal and then from decimal to ASCII. You can use this
chart to help you:https://www.eecis.udel.edu/~amer/CISC651/ASCII-Conversion-Chart.pdf
Answer
2. Describe what it means to say that JPEG is a lossy compression technique and
whether or not it affects the quality of camera pictures.
Answer
JPEG= a lossy compression technique-> reduces the file size of an image by permanently
removing some of the data/bits; makes it easier to store and share images
The Lossy Compression Technique removes less significant information, such as image
quality, that is not easily noticeable by the human eye
3. Give a specific example of a binary sequence that can represent more than one type
of data -- e.g., a number, a color, a character -- and describe how to interpret its
different values.
Answer
Mobile CSP | Student Lesson
Unit 3 | Image Representation
Course Listing: http://course.mobilecsp.org
Character Interpretation: When used in text encoding, 01011010 is mapped to “Z” based
on the ASCII table.
Numeric Interpretation: When treated as a binary number, 01011010 is converted to its
decimal equivalent, which is 90.
Color Interpretation: In image processing, 01011010 could be interpreted as a pixel value,
where 90 represents a shade of grey closer to black (0) rather than white (255).