It’s all bits!
Acknowledgment and Disclaimer: This presentation is supported in part by the National Science Foundation under Grants 1240841, 1225680, 1225719, 1225745, 1225976, and 1226216. Any opinions, findings, and conclusions or recommendations expressed in these materials are those of the authors and do not necessarily reflect the views of the National Science Foundation.
Run-Length Encoding (RLE)
Run-Length Encoding (RLE)
Lossless vs. Lossy Compression
How much data?
256 pixels
16 by 16
62 numbers
RLE
Original Image
How much data?
How much? Depends on how many bits per pixel
256 pixels
16 by 16
62 numbers
RLE
Original Image
Monochrome Image
Monochrome: How much data?
Original
Image
Compressed
Image
Monochrome: How much data?
256 pixels
1 bit/pixel
256 bits
Original
Image
Compressed
Image
Monochrome: How much data?
256 pixels
1 bit/pixel
256 bits
62 numbers
8 bits/number
496 bits
Original
Image
Compressed
Image
Monochrome: How much data?
256 pixels
1 bit/pixel
256 bits
62 numbers
8 bits/number
496 bits
Original
Image
Compressed
Image
>
8-bit Color Image
0 1 2 3 4 5 6 7
R R R G G G B B
1 1 1 0 0 0 1 1
Modified RLE
If there are more than 2 colors, RLE needs two numbers per run: the color and the run length
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
Modified RLE
If there are more than 2 colors, RLE needs two numbers per run: the color and the run length
Twice as many numbers
124 numbers
8 bits/number
992 bits
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
Modified RLE
Original
Image
Compressed Image
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
Modified RLE
256 pixels
8 bits/pixel
2048 bits
Original
Image
Compressed Image
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
Modified RLE
256 pixels
8 bits/pixel
2048 bits
Original
Image
Compressed Image
124 numbers
8 bits/number
992 bits
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
Modified RLE
Original
Image
Compressed Image
124 numbers
8 bits/number
992 bits
256 pixels
8 bits/pixel
2048 bits
<
255,16
255,12, 0,3 255,1
255,10, 0,5, 255,1
255,9, 0,2, 255,1, 0,3, 255,1
255,8, 0,6, 255,2
255,7, 0,2, 255,1, 0,4, 255,2
255,6, 0,7, 255,3
255,3, 0,5, 255,1, 0,4, 255,4
255,4, 0,7, 255,5
255,5, 0,5, 255,6
255,4, 0,5, 255,7
255,2, 0,2, 255,1, 0,1, 255,1, 0,2, 255,7
255,1, 0,2, 255,1, 0,1, 255,3, 0,1 255,7
255,1, 0,1, 255,1, 0, 2, 255, 11
255,0, 0,4, 255,12
255,0, 0,2, 255,14
24-bit Color Image
24-bit Color Image
Four times as many numbers
248 numbers with 8 bits/number
1984 bits
255,255,255,16
255,255,255,12, 0,0,0,3 255,255,255,1
…
255,255,255,0, 0,0,0,4, 255,255,255,12
255,255,255,0, 0,0,0,2, 255,255,255,14
24-bit Color Image
Compressed Image
Original
Image
255,255,255,16
255,255,255,12, 0,0,0,3 255,255,255,1
…
255,255,255,0, 0,0,0,4, 255,255,255,12
255,255,255,0, 0,0,0,2, 255,255,255,14
24-bit Color Image
Compressed Image
Original
Image
255,255,255,16
255,255,255,12, 0,0,0,3 255,255,255,1
…
255,255,255,0, 0,0,0,4, 255,255,255,12
255,255,255,0, 0,0,0,2, 255,255,255,14
256 pixels
24 bits/pixel
6,144 bits
24-bit Color Image
Compressed Image
Original
Image
255,255,255,16
255,255,255,12, 0,0,0,3 255,255,255,1
…
255,255,255,0, 0,0,0,4, 255,255,255,12
255,255,255,0, 0,0,0,2, 255,255,255,14
256 pixels
24 bits/pixel
6,144 bits
248 numbers
8 bits/number
1984 bits
24-bit Color Image
Compressed Image
Original
Image
248 numbers
8 bits/number
1984 bits
256 pixels
24 bits/pixel
6,144 bits
255,255,255,16
255,255,255,12, 0,0,0,3 255,255,255,1
…
255,255,255,0, 0,0,0,4, 255,255,255,12
255,255,255,0, 0,0,0,2, 255,255,255,14
<
Amount of RLE Compression?
The more colors,the more color changes, the more numbers needed.
We’ve seen binary used to
So,...
What does this bit sequence represent?
0100 0001
So,...
What does this bit sequence represent?
0100 0001
Is it the number 65?
So,...
What does this bit sequence represent?
0100 0001
Is it the number 65?
Is it the letter ‘A’
So,...
What does this bit sequence represent?
0100 0001
Is it the number 65?
Is it the letter ‘A’
Is it the color
It Depends!
on how
0100 0001
is used
in an Image?
a Text Message?
a Spreadsheet?
a machine language code?
It’s all bits!
Representing Character Data
Representing Character Data
Binary | Hex | Decimal | Character |
0010 0000 | 20 | 32 | Space |
0011 0000 | 30 | 48 | 0 |
0100 0001 | 41 | 65 | A |
0110 0001 | 61 | 97 | a |
| | | |