Representing Information

DRAFT
Revised 2014 Jan 28

Snyder, chapters 7–8

Learning Objectives

Become able to:

  1. Define the terms bit, byte, octet, binary, hexadecimal, ASCII, Unicode, pixel, subpixel, lossy and lossless compression.
  2. Determine the number of symbols that can be represented with N bits.
  3. Convert hexadecimal to binary and vice-versa
  4. Express decimal numbers (0, 1, 2, …) in binary; interpret their binary representations
  5. Add small binary numbers
  6. Convert English text to ASCII and vice-versa
  7. Describe the RGB representation of colors.
  8. Perform simple transformations on the RGB representation of colors (such as brightening, increase contrast).
  9. Apply the Nyquist rule to determine the sampling rate needed to digitize sound up to a given frequency.
  10. Given the width and height of an image, determine the uncompressed storage size in bytes.
  11. Describe three techniques of image compression.
  12. Classify PNG, GIF, and JPEG as lossy or lossless.
  13. Explain the phrase “bits as a bias-free, universal medium.”

Chapter 7: Basic Data Representations

  1. Digital representations use “digits” — number symbols — fingers — any symbols: discrete, in that something is clearly one symbol or another; they do not blend into one another.

  2. Physical representations based on presence or absence of a phenomenon, such as matter, light, magnetic field.

  3. A bit is a single presence or absence (various interpretations: true/false, 1/0, etc., Table 7.1)

  4. A group of bits represents a symbol.

    We’ve already figured this out:

    No. of bits No. of symbols
    1 2 = 21
    2 4 = 22
    3 8 = 23
    N 2N
    N + 1 2 × (2N) = 2N + 1

    (Table 7.2)

  5. Hexadecimal (“hex”) uses 16 symbols: 0, 1, …, 9, A, B, C, D, E, F (or a–f).

    Its binary encoding: 0 = 0000, 1 = 0001, …, F = 1111. (Count in binary; count in hexadecimal.)

    Why we use it: it is a “compressed” representation of binary, less tedious and less error-prone for humans.

  6. How numbers are represented in binary. Actually just the natural numbers (integers 0, 1, 2, …). Base 2 and base 10 representations.

  7. How text can be represented in binary.

    1. The ASCII 7-bit code; “extended ASCII” (8 bits), officially ISO-8859-1 or Latin-1.
    2. 8 bits = 1 byte or octet
    3. Unicode uses more bits to represent over 100,000 symbols. UTF-8 is actually just one of several forms of Unicode.
  8. Long encodings (using more bits than strictly needed for the symbols) include NATO broadcast alphabet (alpha, bravo, charly, …) and bar codes. Advantages include reduction of errors in the presence of noise, being able to scan in any orientation.

  9. Lab, part 1.

Chapter 8: Representations for Multimedia

Sketchy; add some details

Sound, images, videos. Compression.

  1. We can represent colors as mixtures of red, green, and blue light (RGB). Mixing lights doesn’t work like mixing paints: mixing lights adds wavelengths, while mixing paints subtracts wavelengths (by absorption).

    A pixel is a dot of color. Usually the RGB values are three 8-bit integers (“subpixels”). This allows 23 × 8 = 2563 = 16, 777, 216 different color values.

  2. Decimal to binary conversion using a table algorithm, p. 226.

    Summary: If you can subtract a power of two, do it and write a one. If you can’t, write a zero.

    Example:

    Number to convert  834  322   66  66   2   2  2  2  2  0
    Place value        512  256  128  64  32  16  8  4  2  1
    Subtract           322   66  ---   2  --  --  -  -  0  -
    Binary              1    1    0    1   0   0  0  0  1  0
    
    Check: 11 0100 0010 = 512 + 256 + 64 + 2 = 834
  3. Binary addition: (a) simple, (b) with carry.

    Binary addition is easy, because there are only four “facts” to remember:

    In contrast, for decimal arithmetic we have to know about 100 “facts” about addition ( 5 + 4 = 9, etc.).

    Example: add 1100 + 0010

    Example with carry: add 1010 + 0111. What happens if we have 8 bits available for the result? What if we have only 4 bits available? (Realistically, we probably have 32 or 64, but the same situation can occur with larger numbers.)

  4. Brightening a color by adding a constant to the subpixels. Just keep it within the range 0 to 255.

    Example: brighten (R, G, B) = (200, 128, 96) which is binary (1100 1000, 1000 0000, 0110 0000), by adding 32 (binary 0010 0000).

    Interpret the result (convert to decimal).

    Do the brightening in decimal to check our answer.

    We would do this for every pixel in the image, or in the region to be brightened.

  5. To increase contrast you “stretch” the range of the colors.

    Snyder’s exposition of this uses a grey-scale image, where each pixel has the same values for R, G, and B. You can do the same thing for colored (non-gray) images, but you have to treat each component separately. We’ll consider the red component.

    Suppose the range of reds is from 100 to 150 and we want to increase the contrast, stretching it from 50 to 200.

    The original range is 150 - 100 = 50. The new range is 200 - 50 = 150. The new/old range ratio is 150/50 = 3, so we will have to multiply by 3. There is 3 times as much variation in the R intensity.

    Our transformation is T(R) = Rʹ = 3(R − 100) + 50. (We have to subtract 100 from the original R value to get its difference form the “base”, multiply by 3 to increase the contrast, and add 50 to adjust to the new “base”.)

    We’ll use decimal arithmetic for this. Of course, the computer does it in binary.

    Check the transformation for R = 100 and 150.

    Apply it to R = 110, 140. 

    Blue and green components would get similar treatment.

  6. Sepia transformation: Very old photographs are in shades of brown, obtained by applying the pigment obtained from sepia cuttlefish to the dark areas of the print, which would make the photograph survive longer.1

    Nowadays, image processing software such as Adobe Photoshop and GIMP can apply the sepia tone effect digitally.

    Snyder gives formulas for doing this in the section “Adding Color” (pp. 234–236). We are starting from a grayscale image, and the result is still a monochrome in shades of brown. He gives different transformation formulas for highlights, midrange, and shadow areas. I have seen slightly different formulas. The details are unimportant; the general idea is to transform grays to browns. Brown, in the RGB way of thinking, is dark red, though it may have hints of green and blue.

  7. Digitizing sound: we take samples. Nyquist rule: sample rate must be at least twice the highest frequency to enable accurate reproduction up to the frequency. [Stereo requires twice as many samples.] ADC, DAC.

    Human beings can hear up to about 20,000 hertz (cycles per second). Therefore, for high fidelity, the sampling rate should be at least 40,000 hertz. Standard CD sampling rate = 44,100 hertz.

  8. Not much discussion of sound manipulations, except for MP3 compression, which does not alter the sound perceptibly.

    Let’s use our imaginations:

  9. Size of images uncompressed = width in pixels X height in pixels X 3 bytes per pixel.

  10. Since images can be quite large, compression is important.

  11. Lossy and lossless compression.

  12. Methods of image compression:
  13. Add something here about software freedom

  14. Bits as a bias-free, universal medium

  15. Lab, part 2: ???


  1. For more information on the chemical sepia toning process, see What is Sepia Tone? and Stepwise Sepia Toning.