INFO 101 CH 8

download INFO 101 CH 8

of 68

Transcript of INFO 101 CH 8

  • 8/13/2019 INFO 101 CH 8

    1/68

    Chapter 8

    Representing Multimedia Digitally

  • 8/13/2019 INFO 101 CH 8

    2/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Learning Objectives

    Explain how RGB color is represented in bytes Explain the difference between bits and binary

    numbers

    Change an RGB color by binary addition Explain concepts related to digitizing sound waves Explain the meaning of the Bias-Free Universal Medium

    Principle

  • 8/13/2019 INFO 101 CH 8

    3/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Data

    Digitizing is more than letters, numbers,and metadata

    It is also photos, audio, and video What are the bits doing?

    Digitizing includes other forms of digitizedinformation, known as multimedia

    Same principles are used as with lettersand numbers to encode informationinto bits

  • 8/13/2019 INFO 101 CH 8

    4/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Color and the Mystery of Light

    Color on a Computer Display: Pixels are small points of colored light

    arranged in a Each pixel is formed from three colored lights:

    red, green, and blue. Referred to as RGB (always in that order)

  • 8/13/2019 INFO 101 CH 8

    5/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Showing Colors

    Turning on one light at a time, the displayturns red, green, or blue

    Turning off all of them makes black Turning on all of them makes white All other colors are made by using

    different amounts or intensities of the threelights The three colors do not have to be

    RGB

  • 8/13/2019 INFO 101 CH 8

    6/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Yellow = R + G?

    Combining red andgreen makes yellow

    Taught in elementary

    school that red andyellow are primarycolors

    There is a differencebetween colored lightand colored paint

  • 8/13/2019 INFO 101 CH 8

    7/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Yellow = R + G?

    Paint reflects somecolors and absorbsothers

    When white lightstrikes paint, somelight is absorbed (wecant see it) and somelight is reflected (wesee it)

  • 8/13/2019 INFO 101 CH 8

    8/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Yellow = R + G?

    In the case of a pixel,the light shinesdirectly at our eyes

    Nothing is absorbed Nothing is reflected Just see pure colored

    light

  • 8/13/2019 INFO 101 CH 8

    9/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    LCD Display Technology

    At left in the close-upof an LCD is an arrowpointer with two

    enlargements of it From a distance, the

    pixels appear white Close up, the pixels

    are red, green, andblue colored lights

  • 8/13/2019 INFO 101 CH 8

    10/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Black and White Colors

    The intensity of RGB light is usually givenby a binary number stored in a byte

    Representing the color of a single pixelrequires 3 bytes (1 for each color) Smallest intensity is 0000 0000 Largest value is 1111 1111

    Doing the math from Chapter 7, says therange of values is 0 through 255 foreach color

  • 8/13/2019 INFO 101 CH 8

    11/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Black and White Colors

    Black is the absence of light: 0000 0000 0000 0000 0000 0000

    RGB bit assignment for black

    White is the full intensity of each color: 1111 1111 1111 1111 1111 1111

    RGB bit assignment for white

  • 8/13/2019 INFO 101 CH 8

    12/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Color Intensities

    Consider blue (0000 0000 0000 0000 1111 1111 ) The 8 bits specifying its intensity have

    position values:

    If we want the sub pixel to at half intensity:

    each bit contributes half as much

    power as the bit to its left

    128 64 32 16 8 4 2 1

    1 1 1 1 1 1 1 1

    128 64 32 16 8 4 2 1

    1 0 0 0 0 0 0 0

  • 8/13/2019 INFO 101 CH 8

    13/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Color Intensities

  • 8/13/2019 INFO 101 CH 8

    14/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Decimal to Binary

    Which powers of 2 combine to make thedecimal number?

  • 8/13/2019 INFO 101 CH 8

    15/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Lighten Up

    Changing Colors by Addition To make a lighter color of gray , we change

    the common value to be closer to white.

  • 8/13/2019 INFO 101 CH 8

    16/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Lighter Still

    Imagine that the color lighter still byanother 16 units of intensity for each RGBbyte

    The 16s position is already filled with a 1:1101 1110

    Carry to the next higher place

  • 8/13/2019 INFO 101 CH 8

    17/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Binary Addition

    Same as decimal addition but with onlytwo digits

    Work from right to left, adding digits ineach place position, writing the sum below

    Like decimal addition, there are two cases: Add the two numbers in a place and the result

    is expressed as a single digit Add two numbers in a place and the result

    requires carrying to the next higher place

  • 8/13/2019 INFO 101 CH 8

    18/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Computing on Representations

    When digital information is changedthrough computation, this is computing onrepresentations.

    For example: changingthe brightness andcontrast of a photo

  • 8/13/2019 INFO 101 CH 8

    19/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Brightness and Contrast

    Brightness refers to how close to white thepixels are

    Contrast is the size of difference betweenthe darkest and lightest portions of theimage.

    Photo manipulation software often givesthe values of the pixels in a Levels graph

  • 8/13/2019 INFO 101 CH 8

    20/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Levels Graph

    0 percent is called theblack point, or 000000

    100 percent is the

    white point, or ffffff The midpoint is called

    the gamma point andit is the midpoint inthe pixel range

  • 8/13/2019 INFO 101 CH 8

    21/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Brightness

    We want all the pixelsto be nearer intensewhite, but to keep their

    relative relationships Add 16 to each pixel A pixel which is

    197, 197, 197 becomes213, 213, 213

  • 8/13/2019 INFO 101 CH 8

    22/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Contrast

    Goal is not to shift theLevels diagram right,but rather to stretch it

    out toward the right Add an amount to each

    pixel as before add a smaller amount for

    dark pixels Add a larger amount for

    light pixels

  • 8/13/2019 INFO 101 CH 8

    23/68Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    New Levels Graph

  • 8/13/2019 INFO 101 CH 8

    24/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    New Levels Math

    For every original pixel P o, subtract theamount of the lower end of the range:P o 38

    That tells how much to increase each pixelposition; smaller (darker) numbers getlightened less than larger (lighter)numbers

  • 8/13/2019 INFO 101 CH 8

    25/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    New Levels Math

    Then we multiply by the size of the newinterval divided by the size of the oldinterval

    Add the low end of the original range backin again to return each pixel to its newposition along the second line

  • 8/13/2019 INFO 101 CH 8

    26/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    New Levels Math

    The equation for the value in each pixelposition of the new image:P n = (P o 38)*1.08 + 38

    Round the answer to a whole number

    Try it yourself!For original pixel 239, did you get 255?For original pixel 157, did you get 167?

  • 8/13/2019 INFO 101 CH 8

    27/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Adding Color

    Whenever the 3 bytes differ in value thereis color

    Define highlights as the lightest 25percent of the pixels, and shadows asthe darkest 25 percent of the pixels

    Must count the pixels to know thosevalues: There are 600 800 = 480,000 pixels

    in the image

  • 8/13/2019 INFO 101 CH 8

    28/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Adding Color

    Pick the lowest pixel value and go up tothe next level and keep adding until youhave approximately of the total pixels (inthis case 120,000)

    Pick the highest pixel value and go downto the next level, adding until you have thetop of the total pixels

  • 8/13/2019 INFO 101 CH 8

    29/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Adding Color

  • 8/13/2019 INFO 101 CH 8

    30/68

  • 8/13/2019 INFO 101 CH 8

    31/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Sound

    An object creates sound by vibrating in amedium (such as air)

    Vibrations push the air causing pressurewaves to emanate from the object, whichin turn vibrate our eardrums

    Vibrations are then transmitted by threetiny bones to the fine hairs of our cochlea,stimulating nerves that allow us to sensethe waves and hear them as sound

  • 8/13/2019 INFO 101 CH 8

    32/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Sound

    The force, or intensityof the push,determines the

    volume The frequency (the

    number of waves persecond) of the pushesis the pitch

    continuous (analog)representation of the wave

  • 8/13/2019 INFO 101 CH 8

    33/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Analog to Digital

    To digitize you must convert to bits For a sound wave, use a binary number to

    record the amount that the wave is aboveor below the 0 line at a given point on ourgraph

    At what point do you measure? There are infinitely many points along

    the line, too many to record everyposition of the wave

  • 8/13/2019 INFO 101 CH 8

    34/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Analog to Digital

    Sample or takemeasurements atregular intervals

    Number of samples ina second is called thesampling rate

    The faster the rate themore accurately thewave is recorded

  • 8/13/2019 INFO 101 CH 8

    35/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Nyquist Rule for Sampling

    If the sampling were too slow, soundwaves could fit between the samples andyou would miss important segments of thesound

    The Nyquist rule says that a sampling ratemust be at least twice as fast as thefastest frequency

  • 8/13/2019 INFO 101 CH 8

    36/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Nyquist Rule for Sampling

    Because humans can hear sound up toroughly 20,000 Hz, a 40,000 Hz samplingrate fulfills the Nyquist rule for digital audiorecording

    For technical reasons a somewhat faster-than-two-times sampling rate was chosenfor digital audio (44,100 Hz)

  • 8/13/2019 INFO 101 CH 8

    37/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Process

  • 8/13/2019 INFO 101 CH 8

    38/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Process

    The digitizing process works as follows: Sound is picked up by a microphone

    (transducer ).

    Signal is fed into an analog-to-digitalconverter (ADC), which takes the continuouswave and samples it at regular intervals,outputting for each sample binary numbers tobe written to memory.

  • 8/13/2019 INFO 101 CH 8

    39/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digitizing Process

    The digitizing process works as follows: The process is reversed to play the sound: The

    numbers are read from memory into a digital-to-analog converter (DAC)

    Electrical wave created by interpolation between thedigital values (filling in or smoothly moving from onevalue to another)

    The electrical signal is then input to a speaker whichconverts it into a sound wave

  • 8/13/2019 INFO 101 CH 8

    40/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    How Many Bits per Sample?

    To make the samples perfectly accurate,you need an unlimited number of bits foreach sample

    Bits must represent both positive andnegative values Wave has both positive and negative sound

    pressure The more bits there that are used, the

    more accurate the measurement is

  • 8/13/2019 INFO 101 CH 8

    41/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    How Many Bits per Sample?

    We can only get anapproximatemeasurement

    If another bit is used, thesample would be twice asaccurate

    More bits yields a moreaccurate digitization

    Audio digitalrepresentation uses 16bits

  • 8/13/2019 INFO 101 CH 8

    42/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Advantages of Digital Sound

    A key advantage of digital information isthe ability to compute on therepresentation

    One computation of value is to compressthe digital audio or reduce the number ofbits needed

    What about sounds that the human earcant hear because they are either toohigh or too low

  • 8/13/2019 INFO 101 CH 8

    43/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Advantages of Digital Sound

    MP3 is really a form of computing on therepresentation.

    It allows for compression (with a ratio ofmore than 10:1)

    Another key advantage of digitalrepresentations is that digital can bereproduced exactly

  • 8/13/2019 INFO 101 CH 8

    44/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digital Images and Video

    An image is a long sequence of RGBpixels

    The picture is two dimensional, but think ofthe pixels stretched out one row afteranother in memory

  • 8/13/2019 INFO 101 CH 8

    45/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Digital Images and Video

    Example: 8 10 image scanned at 300 pixels per inch Thats 80 square inches, each requiring 300

    300 = 90,000 pixels (or 7.2 megapixels) At 3 bytes per pixel, it takes 21.6 MB (3 * 7.2)

    of memory to store one 8 10 color image

    Sending a picture across a standard 56 Kb/sphone connection would take at least21,600,000 8/56,000 = 3,085 seconds(or more than 51 minutes)

  • 8/13/2019 INFO 101 CH 8

    46/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Image Compression

    Typical monitor has fewer than 100 pixelsper inch (ppi) storing the picture digitized at 100 ppi is a

    factor of nine savings immediately. A 100 ppi picture still requires more than

    five and a half minutes to send

    What if we want to print the picture,requiring the resolution again?

  • 8/13/2019 INFO 101 CH 8

    47/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Image Compression

    Compression means to change therepresentation in order to use fewer bits tostore or transmit information Example: faxes are a sequences of 0s and

    1s that encode where the page is white (0) orblack (1)

    Use run-length encoding to specify how longthe first sequence (run) of 0s is, then howlong the next sequence of 1s is, then howlong the next sequence of 0s is, then

  • 8/13/2019 INFO 101 CH 8

    48/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Compression

    Run- length encoding is losslesscompression scheme The original representation of 0s and 1s can

    be perfectly reconstructed from thecompressed version

    The opposite of lossless compression is

    lossy compression The original representation cannot be exactly

    reconstructed from the compressed form

  • 8/13/2019 INFO 101 CH 8

    49/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Compression

    MP-3 is probably the most famouscompression scheme MP3 is lossy because the high notes cannot

    be recovered JPG (or JPEG) is a lossy compression for

    images

    Exploits the same kinds of humanperception characteristics that MP -3 does,only for light and color

  • 8/13/2019 INFO 101 CH 8

    50/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    JPEG Compression

    Humans are quite sensitive to smallchanges in brightness (luminance)

    Brightness levels of a photo must bepreserved between uncompressed andcompressed versions

    People are not sensitive to smalldifferences in color (chrominance)

  • 8/13/2019 INFO 101 CH 8

    51/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    JPEG Compression

    JPEG is capable of a 10:1 compressionwithout detectable loss of clarity simply bykeeping the regions small

  • 8/13/2019 INFO 101 CH 8

    52/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    JPEG Compression

    It is possible to experiment with levelsgreater than 10:1

    The benefit is smaller files Eventually the picture begins to pixelate or

    get jaggies

  • 8/13/2019 INFO 101 CH 8

    53/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    MPEG Compression

    MPEG is the same idea applied to motionpictures

    It seems like an easy task Each image/frame is not seen for long Couldnt we use even greater levels of single -

    image compression?

    It takes many stills to make a movie

  • 8/13/2019 INFO 101 CH 8

    54/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    MPEG Compression

    In MPEG compression, JPEG-typecompression is applied to each frame

    Interframe coherency is used Two consecutive video images are usually

    very similar, MPEG compression only has torecord and transmit the differences between

    frames Resulting in huge amounts of compression

  • 8/13/2019 INFO 101 CH 8

    55/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Optical Character Recognition

    Very sophisticated technology thatenables a computer to read printedcharacters

    OCRs business applications include: U.S. Postal Service processing up to 45,000

    pieces of mail per hour (2% error rate)

    In banking, the magnetic numbers at thebottom of checks have been read bycomputers since the 1950s

  • 8/13/2019 INFO 101 CH 8

    56/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Virtual Reality

    Ultimate form of digital representation is tocreate an entire digital world

    Rapidly displaying still images is astandard way to fool our eyes and braininto seeing motion

    Virtual reality applies that idea to our othersenses and tries to eliminate the cues thatkeep us grounded in real reality

  • 8/13/2019 INFO 101 CH 8

    57/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Haptic Devices

    Haptic devices are input/output technologyfor interacting with our sense of touch andfeel

    For example: Haptic glove enables a computer to detect

    where our fingers are and to apply force

    against them, leaving us with the feeling ofholding an object

  • 8/13/2019 INFO 101 CH 8

    58/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Latency

    The system must operate fast enough andprecisely enough to appear natural

    Latency is the time it takes for informationto be delivered

    Long latencies just make us wait, but longlatency can ruin the effect!

    There is an absolute limit to how fastinformation can be transmitted the speedof light

  • 8/13/2019 INFO 101 CH 8

    59/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Bandwidth

    Bandwidth is how much information istransmitted per unit time

    Higher bandwidth usually means lowerlatency

    VR is challenged by both latency andbandwidth limitations

    Creating a synthetic world and delivering itto our senses is a difficult technicalproblem

  • 8/13/2019 INFO 101 CH 8

    60/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Bits Are It!

    4 bytes can represent many kinds ofinformation

    This a fundamental property ofinformation: B ias-Free Un iversal Mediu m Pr incip le :

    Bi t s c an represent a ll d i sc re te inform at ion;

    Bits have no inherent meaning

  • 8/13/2019 INFO 101 CH 8

    61/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Bits: The Universal Medium

    All discrete information can berepresented by bits

    Discrete things things that can beseparated from each other can berepresented by bits

  • 8/13/2019 INFO 101 CH 8

    62/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Bits: Bias-Free

    Given a bit sequence0000 0000 1111 0001 0000 1000 0010 0000

    there is no way to know what information itrepresents

    Meaning of the bits comes entirely fromthe interpretation placed on them by usersor by the computer

    Not Necessarily Binary

  • 8/13/2019 INFO 101 CH 8

    63/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Not Necessarily BinaryNumbers

    Computers represent information as bits Bits can be interpreted as binary numbers Bits do not always represent binary

    numbers ASCII characters RGB colors Or an unlimited list of other things

  • 8/13/2019 INFO 101 CH 8

    64/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Bits are bits

  • 8/13/2019 INFO 101 CH 8

    65/68

  • 8/13/2019 INFO 101 CH 8

    66/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Summary

    We can use arithmetic on the intensities tocompute on the representation, for example,making gray lighter and colorizing a black-and-

    white picture from the nineteenth century. When digitizing sound, sampling rate andmeasurement precision determine how accuratethe digital form is; uncompressed audio requires

    more than 80 million bits per minute.

  • 8/13/2019 INFO 101 CH 8

    67/68

    Copyright 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

    Summary

    Compression makes large files manageable:MP3 for audio, JPEG for still pictures, andMPEG for video. These compact representations

    work because they remove unnecessaryinformation. Optical character recognition technology

    improves our world.

    Virtual reality illustrates the complexities ofconveying information to all of our sensessimultaneously.

  • 8/13/2019 INFO 101 CH 8

    68/68

    Summary

    The Bias-Free Universal Medium Principleembodies the magic of computers throughuniversal bit representations and unbiased

    encoding.