π Lecture 20 β Representing Images
π Overview: This lecture examines how images are digitally encoded and stored in computer memory, moving from simple black-and-white representations to full-color systems. Understanding image encoding is fundamental to graphics, digital photography, and display technologies.
ποΈ Topics Covered
The lecture covers pixel concepts and bitmap encoding methods for black-and-white images, grayscale handling, and color image representation through RGB encoding. It then explores the brightness-chrominance model, image scaling techniques including digital zoom, geometric structures for scaling, and scalable font technologies like TrueType and PostScript.
π Lecture Summary
20. Representing Images
This module explains how visual information is converted into digital data that computers can store and process. The representation capacity follows the principle that n bits can represent 2^n numeric values β for example, 16 bits can represent 2^16 = 65536 numeric values. Binary notation variations include Two's complement for whole numbers and Floating point notation for fractional numbers, which are covered in later modules.
20.1. Pixel
A pixel is short for Picture Element and refers to a collection of dots that form images. The appearance of each pixel is encoded to create a bit map, which is a digital representation of the image. Many display devices and printers operate using the pixel concept.
π Definition β Pixel: The smallest individual element of a digital image, representing a single point in a picture.
20.2. Encoding Method: Pixel to Bitmap
In black and white images, each pixel is represented as one bit β for example, 0 for black and 1 for white. This simple encoding method is often used in Facsimile (fax) technology.
π Formula: 1 bit per pixel β Each pixel stores only two possible values (black or white) π Example: A 100Γ100 black-and-white image would require 100 Γ 100 = 10,000 bits, or 1,250 bytes of storage.
20.3. Encoding Method: Handling shades
To represent shades of grayness, 8 bits are used instead of 1 bit per pixel. This allows for 2^8 = 256 different gray levels, providing smooth transitions between black and white.
π Formula: 8 bits per pixel β 256 possible grayscale values (0 = pure black, 255 = pure white) π‘ Why this matters: More bits per pixel means smoother gradients and higher quality images, but also requires more memory.
20.4. Encoding Method: Colorful Images
Color images use RGB encoding, which allocates one byte for Red, one byte for Green, and one byte for Blue β totaling three bytes to represent one pixel. This system is based on the additive color model where different combinations of red, green, and blue light create millions of colors.
π Definition β RGB Encoding: A color representation method where each pixel is stored as three separate values for red, green, and blue components. π Formula: 3 bytes per pixel β 256 Γ 256 Γ 256 = approximately 16.7 million possible colors π Example: A 1920Γ1080 full-color image requires 1920 Γ 1080 Γ 3 = 6,220,800 bytes (approximately 6.2 MB) of storage.
20.5. Brightness Chrominance
The brightness-chrominance model uses one brightness component and two color components. The brightness component equals the pixel's luminance (the sum of red, green, and blue values). The two color components are Blue Chrominance and Red Chrominance, which represent the difference between luminance and the amount of blue or red in the pixel.
π Definition β Luminance: The brightness of a pixel, calculated as the sum of its red, green, and blue values. π Definition β Chrominance: The color information of a pixel, represented as the difference between luminance and the blue or red component.
20.6. Image Scaling
Image scaling to a larger size requires more pixels to maintain quality. Digital Zoom is a technique that enlarges an image by adding new pixels, often through interpolation methods.
π Example: Enlarging a 100Γ100 image to 200Γ200 requires creating 30,000 new pixels through mathematical estimation rather than actual image capture.
20.7. Geometric Structures for Image Scaling
This approach uses collections of lines and curves combined with Analytical Geometry to determine how geometric structures should be displayed. Unlike simple pixel reproduction, this technique focuses on mathematical descriptions of shapes rather than individual pixel values.
π Definition β Geometric Scaling: A method that describes images using mathematical formulas for lines and curves rather than storing individual pixel values.
20.8. Scalable Fonts
Scalable fonts are designed to be resized without losing quality. Two major technologies are TrueType (developed by Microsoft and Apple) and PostScript (developed by Adobe). These are also popular in Computer Aided Design (CAD) applications.
π Example: A TrueType font character is defined by mathematical curves, so it renders smoothly at any size from 8 points to 72 points without pixelation.
β Key Takeaways
The critical concepts to remember are: pixel representation capacity (n bits represent 2^n values), the progression from 1-bit black-and-white to 8-bit grayscale to 24-bit full color RGB encoding, and the fundamental RGB model where each pixel requires three bytes. The brightness-chrominance model offers an alternative by separating luminance from color information. For scaling, geometric approaches using mathematical curves (like TrueType and PostScript) provide quality advantages over simple pixel interpolation. Students must understand how bit depth directly affects both image quality and storage requirements.
π§ Quick Revision Questions
- How many bits are needed to represent 256 different shades of gray in a pixel?
- In RGB encoding, how many bytes total are used to store one color pixel?
- What is the relationship between luminance and the red, green, and blue components in the brightness-chrominance model?
- What are the two main scalable font technologies mentioned in the lecture?
- If an image is scaled from 100Γ100 pixels to 200Γ200 pixels, how many new pixels must be created?
π Lecture 21 β How to encode the Sound
π Overview: This lecture explores how sound is digitized for storage and transmission, including sampling techniques and bit-depth requirements. It covers binary notation as the fundamental language computers use to represent all data, including sound. Understanding this encoding is critical for grasping how analog information becomes digital.
ποΈ Topics Covered
The lecture explains how sound is encoded by sampling amplitude at regular intervals, with rates varying from 8,000 samples/second for telephony to 44,100 for CDs, using 16 or 32 bits per sample. It introduces MIDI as an alternative that stores performance instructions rather than raw audio. It then transitions to binary notation, explaining positional values using powers of two and providing an algorithm for converting positive decimal numbers to binary.
π Lecture Summary
21.2. How to encode the Sound
β Sample the amplitude of sound at regular intervals and record the values. β 8000 samples per second for long distance telephone communication.
21.3. How Sound data communication takes place
At one end, the system stores amplitude numeric values for each eight thousandth of a second. These values are transmitted over the network. On the other end, the sound is reproduced using the received amplitude values.
21.4. Sample Intervals
The sampling interval depends on the required accuracy and definition. β 8000 samples/second is not enough for high fidelity music recordings. β 44,100 samples per second are recorded in today's CDs. β Data from each sample is recorded in 16 bits (32 bits for Stereo). β 32 * 44100 = million bits/sec.
π‘ Why this matters: Higher sampling rates and bit depths capture more detail, but require more bandwidth and storage.
21.5. Alternative Method: MIDI
MIDI stands for Musical Instrument Digital Interface. It is used in music synthesizers found in electronic keyboards. Rather than storing the sound itself, MIDI encodes directions for producing music. β 2 seconds of sound can be stored in 3 bytes rather than 2 million bits. It is like encoding the "sheet music" to be read by a performer rather than the performance itself. A key limitation is that MIDI recordings can sound significantly different when performed on different synthesizers.
Module 22: Binary Notation
In binary notation, the quantity associated with each position is twice the quantity associated with the position to its right.
22.1. Power Method
To understand binary notation, first recall decimal numbers: in 375, each position represents powers of 10 (10Β²=100, 10ΒΉ=10, 10β°=1), and each position can hold digits 0-9. In the binary system, each position can only hold 0 or 1, and from right to left represents powers of 2: 2β° (1), 2ΒΉ (2), 2Β² (4), 2Β³ (8), 2β΄ (16), 2β΅ (32), 2βΆ (64), 2β· (128), etc.
π Definition β Binary representation: A number system using base 2, where each position is a power of 2 and only digits 0 or 1 are allowed.
π Formula: Decimal value = β (digit at position n) Γ 2βΏ, where n starts at 0 from the right.
π Example: To represent 32 in binary, place a 1 in the 2β΅ (32) position and 0 elsewhere β 00100000. To represent 255, put 1 in all positions from 2β° to 2β· β 11111111, which equals 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
22.2. Algorithm for Finding Binary Representation of a Positive Decimal Number
An algorithm is a set of steps to perform a certain task. The algorithm to convert a positive decimal number to binary is illustrated in Figure 24 (not provided in text, but the concept is: repeatedly divide by 2 and record remainders from right to left).
β Key Takeaways
Sound digitization relies on sampling amplitude at fixed intervals, with higher rates (44,100 Hz for CDs) providing higher fidelity at the cost of more data (up to 1 million bits/second for stereo). MIDI offers an extremely compact alternative by storing performance instructions rather than audio data, but output quality varies by hardware. Binary notation is the foundation of all digital data representation, using powers of two with only 0 and 1 as digits. Converting decimal to binary requires understanding positional values (1, 2, 4, 8, 16, 32, 64, 128...) and an algorithmic approach. The trade-off between data size and quality is a recurring theme in digital encoding.
π§ Quick Revision Questions
- How many samples per second are used for telephone-quality sound versus CD-quality sound?
- What is the data rate (in bits per second) for stereo CD-quality audio, assuming 32 bits per sample?
- How does MIDI differ from standard sound sampling, and what is its main advantage and disadvantage?
- What is the binary representation of the decimal number 255?
- Explain the algorithm for converting a positive decimal number to its binary equivalent.
π Lecture 22 β Algorithm for converting positive decimal to binary number & Binary Addition
π Overview: This lecture presents a systematic algorithm for converting positive decimal numbers to binary, followed by an introduction to binary addition rules. Understanding these foundational concepts is essential for digital logic design and computer arithmetic operations.
ποΈ Topics Covered
The lecture covers the step-by-step algorithm for converting positive decimal integers to binary numbers with a worked example for the number 13. It then introduces the four basic possibilities of binary addition and demonstrates the carry operation through multiple examples.
π Lecture Summary
Algorithm for converting positive decimal to binary number
A structured algorithm is presented for converting positive decimal numbers to binary. The algorithm, illustrated in Figure 24, provides a systematic procedure that can be applied to any positive decimal integer.
π‘ Why this matters: This conversion algorithm is fundamental for understanding how computers store and process numerical data.
π Example: Converting decimal 13 to binary
- The algorithm is applied step by step as shown in Figure 25
- Working through the algorithm reveals the binary equivalent of 13
Binary Addition
This module explains the rules for adding binary numbers. When adding two bits, there are four possible combinations.
π Definition β Binary addition: The process of adding two binary numbers using rules similar to decimal addition, but with only digits 0 and 1.
The four possible cases for adding two bits are:
- 0 + 0 = 0 (no carry)
- 1 + 0 = 1 (no carry)
- 0 + 1 = 1 (no carry)
- 1 + 1 = 0 with a carry of 1 to the next column
π Rule: Addition proceeds from right to left, just like decimal addition. When the sum is 10 (binary for decimal 2), write 0 and carry 1.
π Example 1: Binary addition (Figure 27)
- Two binary numbers are added from rightmost to leftmost columns
- When 1+1 occurs, 0 is placed and 1 is carried to the next column
- The carry is added to the next column's sum
π Example 2: Binary addition (Figure 28)
- Shows additional cases including multiple carries
- Demonstrates handling of carries that propagate through multiple columns
π Example 3: Binary addition (Figure 29)
- Further reinforces the binary addition rules
- Shows the complete process from right to left including all carry scenarios
β Key Takeaways
The lecture establishes two critical skills: first, the algorithm for converting positive decimal numbers to binary must be memorized and applied precisely, with the example of 13 serving as a template. Second, binary addition follows the same right-to-left column addition as decimal, but only four cases exist (0+0, 0+1, 1+0, 1+1), with the last case producing a carry of 1. The carry operation is essential for multi-bit binary addition and directly mirrors how computers perform arithmetic internally.
π§ Quick Revision Questions
- What are the four possible results when adding two binary bits?
- When adding 1+1 in binary, what digit is placed in the current column and what is carried?
- In which direction does binary addition proceed (left-to-right or right-to-left)?
- What is the binary equivalent of the decimal number 13?
- If you have a carry from a previous column and then add 1+1 in the next column, what is the total result in that column?