CS111 – Fundamentals of CS�Lecture 9�Representing Images�
دعاء
ربنا اغفر لنا و لإخواننا الذين سبقونا بالإيمان و لا تجعل فى قلوبنا غلا للذين آمنوا
2
3
Lecture Outline
* ASCII
* UNICODE
4
Reading for this lecture
Section 1.4, and 1.9
2. External links and sources to help
you understand the materials.
5
دعاء
ربنا آتنا فى الدنيا حسنة و فى الآخرة حسنة و قنا عذاب النار
6
كيف تنجح فى الكلية و فى حياتك
أولا: نم مبكرا عقب العشاء
1- وجعلنا الليل لباسا وجعلنا النهار معاشا
2- اللهم بارك لأمتي في بكورها
3- نام بكير فيق بكير شوف الصحة كيف بتصير
7
كيف تنجح فى الكلية و فى حياتك
ثانيا: إن الصلاة كانت على المؤمنين كتابا موقوتا
8
كيف تنجح فى الكلية و فى حياتك
ثالثا: أمك ثم أمك ثم أمك ثم أبوك
9
كيف تنجح فى الكلية و فى حياتك
رابعا: حدد هدفك
10
كيف تنجح فى الكلية و فى حياتك
خامسا: اصنع الفرصة
https://www.youtube.com/watch?v=k5M5Fz1oLvo
��
11
كيف تنجح فى الكلية و فى حياتك
سادسا: المثابرة المثابرة المثابرة
كن نملة
12
How can we represent Images?
like this?
1-13
https://mostafanageeb.com/
https://www.youtube.com/watch?v=OHZyrFlpMVE
How can we represent Images?
14
1 0
2. Image representation
15
2. Image representation
16
B&W - Gray – Colored Pictures
17
Black & White Bitmap Images
000000001111111111111111111111111111111111111111111111111111111111111
111111110001111111111111111111111111111111111111111111111111111111001
111000000000011111111111111111111111111111111111111111111111111111001
110000000000001111111100000111111111111111111111111111111111111111111
111100000000011111111000001111111111111111111111111111111111111111111
111111111111111111110000001111111111111111000001111111111111111111111
111111111111111111110000001111111111111111000000111111111111111111111
111111111111111111110000011111111111111111000000011111111111111111111
111100000001111111110000011111111111111111100001111111111111111111111
111110000000011111110000011111111111111111111111111111111111101111111
111100000000001111110000001111111111111111111111111111111100000001111
111100000000001111110000001111111111111111111111111111111100000001111
111100011100001111110000001111111111111111111111111111111100000000111
111000011110000011110000001111111000011111111100001111111000111000001
111000011111000011110000001111110000011111111000001111111000111000001
110000011110000011110000001111110000011111111100000111110000111100001
110000001111000001111000001111111000001111111100000011110000111100001
110000000000000011111000011111111100001111111110000011110000000000001
111000000000000011111000011111111110000111111110000011110000000000001
110000000000000111111000111111111110000111111111000011100000000000001
111100000000000111110001111111111110000111111111000011111000000000001
111111111111111111110001111111111110000111111111000011111100000000001
111111111111111111111111111111111000001111111110000111111111111100001
111111111111111111111111111111111000011111111000000111111111111000001
111111111111111111111111101111100000011111100000001111111111100000011
111111111111111111111111100000000000110000000000011111100000000000111
111111111111111111111111110000000001111100000000111111110000000001111
111111111111111111111111110000000011111110000001111111111100000001111
111111111111111111111111111111000111111111000111111111111110000111111
Black & White Bitmap Images
Gray Bitmap Images
20
Example: 2-bit per pixel
21
1
1
=
(white)
0
1
=
(dark grey)
0
1
=
(light grey)
0
0
=
(black)
Example: 4-bit per pixel
22
Colour representation
23
24-bits -- the True colour
24
Methods Representing Images
= Gray Image
26
RGB
28
Bitmap Images
Bitmap Images
Storing Bitmap: (1) Direct Coding
BYTE 1 R | BYTE 2 G | BYTE 3 B | Color Name |
0 | 0 | 0 | Black |
0 | 0 | 1 | Blue |
0 | 1 | 0 | Green |
1 | 0 | 0 | Red |
Can we use less than 3 pixels?
Storing Bitmap: (2) Lookup table
0 | r | g | b |
1 | 11111111 | 11111111 | 11111111 |
2 | 00100000 | 1000000 | 00100000 |
3 | | | |
| | | |
| | | |
255 | | | |
Storing Bitmap: (2) Lookup table
Bitmap Images
Bitmap Images
A pixel is the smallest display
element that makes up the images
seen on televisions and computer
monitors.
Advantages of Bitmap Images
Advantages of Bitmap Images
Disadvantages of Bitmap Images.
Bitmap Images
39
Vector Images
Advantages of Vector Images
Advantages of Vector Images
Advantages of Vector Images
Disadvantages of Vector Images
45
3. Representing Sound
Convert Analog to Digital
Analog-to-Digital-to-Analog
History
Characteristics of Sound
Two Ways to Represent Sound
(1) Sampling�Digital Representation of Audio
The sound wave represented by the sequence 0, 1.5, 2.0, 1.5, 2.0, 3.0, 4.0, 3.0, 0
1-53
Sampling
54
Nyquist Theorem
For lossless digitization, the sampling rate should be at least twice the maximum frequency response.
fs > 2*fm
Quantization
3-bit Quantization
A 3-bit binary (base 2) number has 23 = 8 values.
0
1
2
3
4
5
6
7
Amplitude
Time — measure amp. at each tick of sample clock
4-bit Quantization
A 4-bit binary number has 24 = 16 values.
0
2
4
6
8
10
12
14
Amplitude
Time — measure amp. at each tick of sample clock
Digitizing Sound
59
Zoomed Low Frequency Signal
Capture amplitude at these points
Lose all variation between data points
Digitizing Sound
60
Zoomed Low Frequency Signal
Capture amplitude at these points
Lose all variation between data points
The Digital Audio Stream
It’s just a series of sample numbers, to be interpreted as instantaneous amplitudes: one for every tick of the sample clock.
Previous example:
11 13 15 13 10 9 6 1 4 9 15 11 13 9
This is what appears in a sound file, along with a header that indicates the sampling rate, bit depth and other things.
16-bit Sample Word Length
A 16-bit integer can represent 216, or 65,536, values (amplitude points).
We typically use signed 16-bit integers, and center the 65,536 values around 0.
32,767
-32,768
0
Audio File Size
CD characteristics…
- Sampling rate:
44,100 samples per second (44.1 kHz)
How big is a 5-minute CD-quality sound file?
- Sample word length:
16 bits (i.e., 2 bytes) per sample
- Number of channels: (mono or stereo)
2 (stereo)
https://stackoverflow.com/questions/13556265/how-to-calculate-audio-file-size
64
4. Data Compression (Section 1.9)
65
4. Data Compression (Section 1.9)
66
4. Data Compression (Section 1.9)
67
Run Length Encoding Example
| | | | | | | | | | | | | | | | | | 4, 11 |
| | | | | | | | | | | | | | | | | | 4, 9, 2, 1 |
| | | | | | | | | | | | | | | | | | 4, 9, 2, 1 |
| | | | | | | | | | | | | | | | | | 4, 11 |
| | | | | | | | | | | | | | | | | | 4, 9 |
| | | | | | | | | | | | | | | | | | 4, 9 |
| | | | | | | | | | | | | | | | | | 5, 7 |
| | | | | | | | | | | | | | | | | | 0, 17 |
| | | | | | | | | | | | | | | | | | 1, 15 |
4.1
68
Run Length Encoding Example
| | | | | | | | | | | | | | | | | | 4, 11 |
| | | | | | | | | | | | | | | | | | 4, 9, 2, 1 |
| | | | | | | | | | | | | | | | | | 4, 9, 2, 1 |
| | | | | | | | | | | | | | | | | | 4, 11 |
| | | | | | | | | | | | | | | | | | 4, 9 |
| | | | | | | | | | | | | | | | | | 4, 9 |
| | | | | | | | | | | | | | | | | | 5, 7 |
| | | | | | | | | | | | | | | | | | 0, 17 |
| | | | | | | | | | | | | | | | | | 1, 15 |
4.1
69
Run Length Encoding Example
4.1
70
Dictionary Encoding
4.4
71
Dictionary Encoding
4.4
72
Compressing Images
73
What are the basic graphic file formats?
Which file formats should you use and why?
How does the format affect the file size?
How does the format handle compression?
74
TIFF
Tagged Image File Format
75
GIF
Graphics Interchange Format
76
JPEG
Joint Photographic Experts Group
77
JPEG
78
“Lossy” compression types:
Original
Compressed
9:1
“averaging”
79
Compressing Audio and Video
http://computer.howstuffworks.com/mp3.htm
80
Uncompressed
Homework …..
82