1 / 62

Objectives

Objectives. Understand compression algorithm. Given an input string, create the compressed code. Understand HOW we compress. Understand good properties of compression algorithms Understand phrase “ time/space ” tradeoff

aurek
Download Presentation

Objectives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives • Understand compression algorithm. • Given an input string, create the compressed code. • Understand HOW we compress. • Understand good properties of compression algorithms • Understand phrase “time/space” tradeoff I’m guessing photo editing is not new to most of you. I want you to consider it from a TECHNICAL point of view • Understand the way images are stored • Understand that editing images is really doing simple math operations on the pixels • Revisit the idea of compression - only on images

  2. Objectives (continued) I’m guessing sound editing is new to most of you. • Understand the way sound is stored • Understand that editing sound is really doing simple math operations on the samples • Revisit the idea of compression - only on sound • Units of storage understood

  3. Terms • compression • lossless/lossy • adaptive • time/space trade-off • fully saturated • dictionary (in data structure terminology) • pixel • frequency • force/intensity • sampling rate • Nyquist rule • HZ • bits per sample • Bandwidth • byte/kilobyte/megabyte/gigabyte

  4. Life Skills • Assumes you WILL use the computer. It seems unlikely that you will have more of a need for understanding the details of climate, rocks, or energy than computers! • Terminology is important in being able to communicate to technology professionals. • Being able to ask for what you want increases the chances you will get it. • Being able to speak clearly about technology is impressive in a variety of business settings. • Compression is a key feature of all kinds of storage (images, sound, text). Understanding compression makes you a better user of a computer. • Image editing is a useful skill. • Appreciation of what is “underneath the hood” is important it understanding new developments. • Knowing how editing is done makes it possible for you to request reasonable extensions. Better designer.

  5. Life Skills (continued) • Good project management is asking the right questions. • IT (Information technology) people are very focused on the how, not on the what. The most common mistakes they’ll make are errors caused by doing the wrong things, not by doing things wrong. • The best way to communicate with an IT organization is to talk to members of the organization as if they’re from a foreign country and don’t speak English very well. • Overly-specific definition of system requirements by the business is a leading cause of excessive IT spending and low IT morale. When you appreciate the expertise they have, you will be more comfortable specifying the broad strokes. • Design jobs that will intrigue and challenge your best performers. • Encourage management to strengthen its connections with people at all levels of the company.

  6. Chapter 8: Light, Sound, Magic: Representing Multimedia Digitally

  7. How are characters stored? We represent characters by a pattern of bits. Here is part of a seven bit scheme. Includes special symbols, upper and lower case, blank. Computer normally work with 8 bits. Originally the 8th bit was used for parity, but recently it has been used to double the size of the character set. Notice the ordering of capitals and lower case which allows (a) alphabetizing (b) character arithmetic (converting upper to lower case) Notice two how many different characters are possible with just seven bits. 27 = 128

  8. Note that when digits are stored in character format, it is not convenient to do math or comparisons.

  9. Compression • Despite the massive capacity of modern computer storage devices, there is still a need for systems to store data as efficiently as possible. • By coding data before it is stored, and decoding it when it is retrieved, the storage capacity of a computer can be increased at the expense of slightly slower access time. • Classic time/space trade-off • The process of compressing and decompressing the data is normally done automatically by the computer, and the user need not even be aware that it is being done except that they might notice that the disk holds more, and that it takes a little more time to get files from thedisk. • Sometimes the system can even be faster using compression because there is less to read from the disk, and this more than compensates for the small amount of time needed to decompress the material.

  10. Compression • Suppose we wanted to save room on the disk. How could we store the contents of a book in less space? • eliminate boring chapters (lossy) • eliminate connecting words (lossy) • avoid repetition (lossless)

  11. One compression idea • Look for similarities of character patterns. • Instead of writing “Answer the questions written in green” – you replace it with a pointer to “that” • Instead of looking for full sentences, it is more practical to look for a series of letters. • A bunch of underscores could be written as 80_ but that is very limiting. • Do you think this would really help much? • How much savings would be “worth it”?

  12. Lempel Ziv Welch • Many methods of compression have been invented. The principle of pointing to earlier occurrences of chunks of text is a popular technique, often referred to as “Lempel-Ziv-Welch coding,” or LZW coding, after professors who published several important papers in the 1970s and 1980s about this kind of compression.  • it adapts to whatever sort of data is being coded— Spanish/Japanese • adapts to the subject of the text, since any word that is used more than once can be coded with a pointer.  • LZ coding will typically halve the size of the data being compressed. It is used in popular archiving programs with names like Zip and ARC, and in “disk doubling” systems.

  13. Idea of LZW compression is fairly simple • Keep a “dictionary” of sequences you might see again. • Generate new entries by old entries followed by a letter than really occurred in practice • New entries are not used until the NEXT time. input aaaba if aaa is in dictionary (but not aaab), use the code for aaa but then ADD the code for aaab to the dictionary. • Dictionary grows and can be regenerated!

  14. Lempel-Ziv-Welch LZW compression Input: characters to be encoded from a known alphabet Output: series of numeric codes for input Variables: StrTable: list of all (code,string) pairs P current string C single character 1 Initialize StrTable with single character strings2 P ← first input character3 WHILE not end of input stream4 C ← next input character5 IF P + C is in the StrTable (concatenation)6 P ← P + C7 ELSE8   output the code for P9 add P + C to the StrTable 10 P ← C11 END WHILE12 output code for P

  15. In Class Feb 23 #1 Draw a box around any sequence of two or more letters that is repeated earlier in the lyrics.   Draw an arrow from this selection to the previous letters I don't care who started it! You're grounded until your 36!Get your story straight, and tell the truth for once for heaven's sake!And if all your friends jumped off a cliff would you jump too?If I've said it once, I've said at least a thousand times before That: You're too old to act this way! It must be your father's DNA!Look at me when I am talking. Stand up straighter when you walk.A place for everything, and everything must be in place.Stop crying or I'll give you something real to cry about! Oh! #2 List characteristics of a good compression algorithm.

  16. In Class Feb 23 #1 Draw a box around any sequence of two or more letters that is repeated earlier in the lyrics.   Draw an arrow from this selection to the previous letters #2 List characteristics of a good compression algorithm. effective – compresses adaptive lossless fast simple

  17. Announcements • Homework Friday. Due Midnight. Alice tutorials. You can turn in ONLY ONE file. It can be a zip file, but a single word processing document is likely the easiest for you. Being able to create a document with pictures it in is very useful. • If you do not know how to figure out what is due and when it is due, ask your neighbor. If neither of you know, flag me down during group work.

  18. Example 1: LZW Compression Step 1 BABAABAAA P=B  A C=A

  19. Example 1: LZW Compression Step 2 BABAABAAA P=AB C=B

  20. Example 1: LZW Compression Step 3 BABAABAAA P=BAA C=A

  21. Example 1: LZW Compression Step 4 BABAABAAA P=ABA C=A

  22. Example 1: LZW Compression Step 5 BABAABAAA P=AA C=A

  23. Example 1: LZW Compression Step 6 BABAABAAA P=AA C=empty

  24. LZW Decompression • The LZW decompressor creates the same string table during decompression. • It starts with the first table entries initialized to single characters. • The string table is updated for each character in the input stream, except the first one. • Decoding achieved by reading codes and translating them through the code table being built.

  25. LZW Decompression Algorithm Input: Coded input Output: Decoded output, StrTable PrevCode: last input code Curr: current input code 1 Initialize StrTable with single characters from the alphabet 2 PrevCode = first input code 3 output translation of PrevCode 4 WHILE not end of input stream 5 Curr ← next input code from input stream 6  IF Curr is not in the StrTable 7 Str ← translation of PrevCode 8   Str ← Str + C 9 ELSE 10  Str ← translation of Curr 11 output Str 12   C ← first character of Str 13   add translation of PrevCode + C to the StrTable 14 PrevCode ← Curr 15 END WHILE

  26. Example 2: LZW Decompression 1 Example 2: Use LZW to decompress the output sequence of Example 1: 1 0 2 3 0 6

  27. Example 2: LZW Decompression Step 1 <1><0><2><3><0><6>

  28. Example 2: LZW Decompression Step 2 <1><0><2><3><0><6>

  29. Example 2: LZW Decompression Step 3 <1><0><2><3><0><6>

  30. Example 2: LZW Decompression Step 4 <1><0><2><3><0><6> \

  31. Example 2: LZW Decompression Step 5 <1><0><2><3><0><6>

  32. Exercises • Use LZW to trace encoding the string ABRACADABRA.

  33. Computing On Representations • Changing the Colors of a Moon Photo • Imagine a scanned black and white photo of the moon • In the computer, the pixels of the photo form a long sequence of RGB triples. What values do they have? • They are all black, white, or gray • Suppose you want a colorized version?

  34. Removing the Smudge • You have very dark gray values (28,28,28) from a smudge on the scanner's glass • To remove the smudge and transform the pixels into the colors you remember seeing • Anything very close to black (first 2 digits are 00 - 00xxxx) can be changed to black (000000) • Algorithm for this is: Any three RGB bytes, each of whose first 2 bits are 00, are replaced with all zeros

  35. The following image shows the three "fully saturated" (one of values is at max) faces of a 24-bits per pixel RGB cube, unfolded into a plane:

  36. Making the Moon Orange • To shift color of moon to orange, change the white pixels: • Pick a shade of orange, say (255,213,132) • Change all the white pixels (255,255,255) to this shade • This will not change the gray of the craters • To change Light Gray into Orange Tint: • Red byte: Leave unchanged • Green byte: reduce green slightly (subtract 42) • Blue byte: reduce blue significantly (subtract 123)

  37. Boosting the Red • You decide the gray parts of the moon need to be more luminous • Boost the red • Shifting the red in the orange pixels to 255 is too red • Split the difference. Add half the difference between the current value and pure red

  38. InClass Feb 25 • Log on to CSILM as a <guest> • Do exercise Photo Editing. • There may be more questions than you can finish. Do as many as is reasonable. • Turn in paper/pencil answers at the end of class.

  39. Feb 27 PARTICIPATION 3 – Laptop survey. Do today (if you haven’t already) Debriefing on Photo Editing • Difference between “what” is being done (blurring) and “how” it is being done (averaging surrounding pixels) • Reverse engineering actually important it debugging – What would cause the results I’m seeing • Look at compression in geek/smart resize. Lossy compression. Look for areas with little “information density” Download Audacity. • Grab a sound file. bbback.mp3 http://wavcentral.com/commercials.htm • We have a very short exercise with Audacity (under CSILM Sound Editing) – but you will need to have audacity downloaded.

  40. JPEG compression • Used for still images • Our eyes are not very sensitive to small changes in hue (gradation of color), but are sensitive to small changes in brightness • Store a less accurate description of hue (fewer pixels) • Gets a 20:1 compression ratio without eyes being able to perceive the difference

  41. Ethics in science is a hot button topic

  42. Photo Editing Ethics – for a journalist?What should be allowed? Brightness/contrast controlColor correctionCropping a frame to fit the layoutRetouching of dust & scratches Adding, moving, or removing objects within the frameColor change other than restoring what subject looked likeCropping a frame in order to alter its meaningFlopping a photograph (left/right reversal)Printing a photograph in other than "true" orientation Combining two photographs into one

  43. BACK IN THE U.S.S.R. Grandpa always wanted to visit the Soviet Union (circa May Day, 1937), and with some digital help, it’s almost as if he’s there.

  44. Revisionist history, it seems, can be practiced by just about anyone. • Andy was at the wedding, right? • “It used to be that photographs provided documentary evidence, and there was something sacrosanct about that,” said Chris Johnson.

  45. Original photo had gray sky

  46. montage: A single pictorial composition made by juxtaposing or superimposing many pictures or designs or sounds.

  47. Digitizing Sound • An object creates sound by vibrating in a medium such as air • Vibrations push the air • Pressure waves emanate from the object and vibrate our eardrums • The force, or intensity of the push determines the volume • The frequency (number of waves per second) is the pitch

More Related