Image Compression and Storage Image Manipulation
Transcription
Image Compression and Storage Image Manipulation
Overview of Computer Science CSC 101 — Summer 2011 Digital Images: C Compression i and dM Manipulation i l ti Lecture 15 — July 26, 2011 Announcements • • • • • Lab 5 today. Midterm grades *should* should be up soon Writing Assignment #5 due Today Writing Assignment #6 due Thursday Quiz #3 on Friday 2 Objectives • Digital images – Storage – Compression – Manipulation 3 1 Storage of Digital Images • Digital images are numbers, stored in files • Each image file is of some file type – The file type yp dictates how those numbers are stored in the file – Choice of file type typically dictated by intended use • Most image file types compress the image data – Compression allows a series of numbers to be stored in a more compact way 4 Storage of Digital Images • If there is no compression – The numbers for each pixel are stored in the file – This kind of file is called a bitmap • Filename will have a .bmp extension – Bitmap images are no longer common because they can take up so much storage space • Good compression techniques have been developed • A compressed image may appear similar or identical to the bitmap, but be only a fraction of the size 5 Image Compression • Compression is the act of making a data file smaller – – – – Takes up less space on disk Transfers more quickly over a network A compressed file must be uncompressed to be used There are two categories of image compression commonly used –– lossless and lossy compression • Lossless image compression – After compression and decompressed, the original image is reproduced exactly – No information (image detail) is lost • Lossy image compression – Exact reproduction of the original is not guaranteed – Information (detail) that is lost cannot be recovered 6 2 Digital Image File Formats • JPEG (Joint Photographic Experts Group) – .jpg, .jpeg, or.jpe filename extensions – – – – Lossy compression with variable controls Ideal for photographs Not so good for solid-color graphics Frequently used in Web pages • GIF (Graphic Interchange Format) – .gif filename extension – – – – – Indexed color image (up to 256 colors) Lossless compression Ideal for simple graphics with solid colors Not so good for photographs Also frequently used in Web pages 7 Digital Image File Formats • PNG (“PNG’s not GIF”) (www.libpng.org) – .png filename extension – Uses both lossy and lossless compression • Can be used both for graphics and photos, though JPEG usually best for photos – Lossless l compression i similar i il to GIF: • Indexed color (but not limited to 256 colors) • Run-length encoding (RLE) – The GIF format was subject to royalties due to a controversial patent (now expired) on a compression method • The PNG format was created to avoid that patent 88 Storing Digital Images Graphic as BMP (307 KB) Graphic as GIF (20 KB) Graphic as PNG (17 KB) Graphic as JPEG (12 KB) 99 3 Storing Digital Images Photo as JPEG (99 KB) Photo as PNG (17 KB) Photo as GIF (20 KB) 10 10 Image Compression • Lossless techniques – Used in GIF and PNG images for solid-color graphics • Indexed color • Run-length R l th encoding di • Lossy techniques – Used in JPEG and PNG images for photographs 11 11 Indexed Color • Indexed color is a lossless compression technique that avoids storing unnecessary information (used by the GIF format) • Only those colors actually used in the image are stored • The set of up to 256 chosen colors is called a palette – If more than 256 colors are needed, then this may not be an appropriate method • Indexed color image files are very compact – Uses 1 byte/pixel (or fewer) • instead of 3 (or more) – GIF files are further compressed using run-length encoding 12 4 Indexed Color • An indexed color image has up to 256 different colors – Can choose any colors of the rainbow for those 256 – Different images will have different color palettes 13 13 Lossless Compression • Run-length encoding (RLE) is another method of lossless compression – Solid-color graphics often have many consecutive pixels that are the same color – Instead of storing each individual (identical) pixel in a consecutive series, a pixel can be stored just once, with a repetition count – Consider Spongebob • Let’s just look at his eyebrow 14 Lossless Compression 60 20 • In this part of the image, the top row of 60 pixels is all one color – Instead of storing 60 yellow pixels, RLE allows us to store just one yellow pixel, and the instruction to repeat that pixel 60 times – For solid color graphics, this can result in huge file-size reduction • The full Spongebob image has 500×500 resolution (250,000 pixels), but the GIF file is only 21,900 bytes because of run-length encoding • 97% reduction in file size in this image 15 5 Lossy Compression • Indexed color and run-length encoding work well in solid-color images, but what about images with complex coloring and shading, such as photographs? – Indexed color and RLE are not good choices, because they work best with a small number of solid colors – Other methods can be used—but to get a reasonable file size reduction, lossy compression techniques are required • The JPEG file format exploits the nature of human vision and perception – For example, we’re more likely to notice subtle variations in brightness than subtle variations in hue – Compression that reduces the detail in the variations of brightness may be undetectable by eye – JPEG makes use of a number of techniques that maximize compression while minimizing noticeable reduction in quality 16 Lossy Compression • The JPEG file format uses lossy compression – User has a choice of degree of compression used, used and therefore amount of information lost • An example of information loss on compression: • Here is a JPEG image at basic compression (‘Quality’ = 100) – 111 KB file size • (the original, uncompressed photo bitmap is 496×770, or 1.15 MB) 17 Lossy Compression • The same image at ‘Quality’ = 85 – Still 496×770 – 61 KB file size 18 6 Lossy Compression • The same image at ‘Quality’ = 50 – Still 496×770 – 15 KB file size 19 Lossy Compression • The same image at ‘Quality’ = 25 – Still 496×770 – 8 KB file size 20 Lossy Compression • The same image at ‘Quality’ = 1 – – – – Still 496×770 4KB file size Original JPEG file was 111 KB While not good for a large blowup, perhaps a high level of compression provides sufficient quality for a small version of the image? 21 7 Image Editing • Digital images – like any digital information – can easily be changed – It’s just a bunch of numbers • Reasons why someone may want to change an image: – – – – – Enhance aesthetics (artistic reasons) Correct ‘errors’ (judgment call about what constitutes an ‘error’) Clarify information (e.g. “false color” technical images) Influence opinion (editorializing; marketing) Alter history • Images form an important part of the historical record – Alter current ‘reality’ • Our universe is only what we experience directly – and much of that has been presented to us by someone else 22 Image Manipulation • Because images may be manipulated so easily, we must critically evaluate the images that we see • The ethics of image modification… – When an image is changed, is it a deception, or a clarification? – What is the intent? Is it purposeful? – What are the potential consequences? – Context and expectation • Almost anything is OK for marketing or entertainment • “News” reporting must meet a higher standard • PLEASE! Check out the website. – http://www.cs.dartmouth.edu/~farid/Hany_Farid/PhotoTampering0 .html • Many of the examples from today can be found here. 23 23 False Coloring • Commonly used with technical images to make information clearer Gustav Hearing Hannah Ike Vision Hurricanes Gustav, Hannah, and infant Ike (9/1/2008) Richmond, VA Brain scan 24 24 8 Correcting ‘Errors’ 25 25 Image Manipulation • Is seeing believing? – A couple of fish stories… Are either of these true photos? 26 Image Manipulation www.snopes.com/photos/shark.asp 27 9 Image Manipulation As for the giant catfish: www.snopes.com/photos/noodling.asp 28 Another Shark Tale www.snopes.com/photos/animals/scubashark.asp 29 Another Shark Tale www.snopes.com/photos/animals/scubashark.asp 30 10 Some Image Manipulation Examples • Almost any marketing image • Even ‘respectable’ magazines like National Geographic • Many images in supermarket tabloids 31 Some Image Manipulation Examples • Two magazines had different ideas of how Cameron Diaz should look http:/www.thefab.net/topics/culture_general/cg02_doublediaz.htm http://web.archive.org/web/20040619234038/http://www.thefab.net/topics/culture_general/cg02_doublediaz.htm 32 Some Image Manipulation Examples • How about a news anchor? • Katie Couric loses weight… weight www.popphoto.com/photographynewswire/2916/katie-couric-photo-airbrushed.html 33 11 What is “Beauty” An interesting Web site concerning the erosion of self-image among young women based on distorted ideals of human beauty as presented by the media: – campaignforrealbeauty.com – The latter half of this 45-second video focuses on digital image manipulation techniques 34 Some Image Manipulation Examples • Brad Pitt and Angelina Jolie – Rumored to have a ‘relationship’ (April 2005) • It was just a rumor at the time… • …since he was still married to Jennifer Aniston – The p picture of Pitt was taken on a Caribbean island, in January 2005 – The picture of Jolie was taken in Virginia some time in 2004 • On page 8 is a disclaimer noting the image is a “composite of two photographs” – This composite was purchased from a London photography agency, for $500,000 • So, were they really “Caught Together!” on vacation? 35 Some Image Manipulation Examples • The previous examples were modifications of photographs • Here’s a completely artificial (computer generated) image by Mihai Anghelescu 36 12 Some Image Manipulation Examples • Modifying images to be ‘politically correct’ – The Beatles’ Abbey Road album cover shows Paul holding a cigarette – Some US poster companies have air-brushed the cigarette out of the image 37 www.thememoryhole.org/arts/abbey-road.htm Some Image Manipulation Examples • Image editing for marketing purposes is usually not a problem… • But, images can also be manipulated for less benign purposes… 38 Some Image Manipulation Examples • Falsification of history in Stalin’s Soviet Union – Before the age of digital images, but image manipulation was still a major part of soviet politics – The Commissar Vanishes by D D. King (1999) has many examples (http://www.newseum.org/berlinwall/commissar_vanishes/) Nikolai Yezhov, commissar of water transport, is shown with Stalin in front of the Moscow-Volga canal. By 1938 he was out of favor with Stalin. In 1940 he was executed and removed from the historical record. 39 13 Some Image Manipulation Examples • Falsification of history in Stalin’s Soviet Union – Before the age of digital images, but image manipulation was still a major part of soviet politics – The Commissar Vanishes by D D. King (1999) has many examples (http://www.newseum.org/berlinwall/commissar_vanishes/) Leon Trotsky is shown here with Lenin and others. He came to disagree with the Soviet Central Committee. He was exiled in 1928. Murdered in 1940. And removed from the historical record. 40 Some Image Manipulation Examples • 1960’s Soviet Union – Refused to admit failures in the space race – Eliminated all traces of cosmonauts who perished • http://www.lostcosmonauts.com/default.htm 41 41 Some Image Manipulation Examples • Heroic portrait of Lincoln widely posted in schools and government buildings after his assassination – Lincoln’s head superimposed on the body of SC senator John Calhoun 42 www.museumofhoaxes.com/photos/02calhoun.html; memory.loc.gov/ammem/today/mar18.html 14 Some Image Manipulation Examples • Iranian missile launch demonstration (7/9/2008) http://thelede.blogs.nytimes.com/2008/07/10/in-an-iranian-image-a-missile-too-many/ 43 43 Image Manipulation Examples • Does the cropping of this photo change its meaning? 44 More BP Controversy Meta info for picture says it was created (taken) in 2001, not July 16 2010 But can you spot other mistakes? 45 15 More BP Controversy Meta info for picture says it was created (taken) in 2001, not July 16 2010 But can you spot other mistakes? 46 Image Manipulation Examples • Egyptian president Hosni Mubarak moved to the front of the procession in Egyptian newspapers – http://www.guardian.co.uk/world/2010/sep/16/mubarak-doctored-red-carpet-picture 47 Some Image Manipulation Examples • The Ballplayer Vanishes – After Ricky Clemons was jjailed and expelled p from the University of Missouri's basketball team, his image was removed from their 2003-04 basketball media guide http://www.columbiatribune.com/2003/Dec/20031204Feat001.asp 48 16 Some Image Manipulation Examples • After spending time in prison, Newsweek wanted to show Martha Stewart as Ready for Prime Time Time” “Ready • But, she was not available for a photo shoot – Newsweek created the photo by placing an older head shot on a model’s body www.nppa.org/news_and_events/news/2005/03/newsweek.html 49 Some Image Manipulation Examples • In 1989, TV Guide wanted to attract attention to an article about Oprah – Placed Oprah’s head on the body from a 1979 promo photo of Ann-Margret 50 www.museumofhoaxes.com/photos/oprah.html Some Image Manipulation Examples Some (in)famous wartime photographs – Gettysburg: “A Harvest of Death” by Timothy O’Sullivan (1863) • Rearranged corpses on the battlefield for emotional impact memory.loc.gov/ammem/cwphtml/cwpcam/cwcam2.html – Spanish civil war photo “Death of a Spanish Loyalist” (1936) by Robert Capa • Some have suggested gg it was staged g www.photographers.it/articoli/cd_capa/img/falling%20soldier.pdf 51 17 Some Image Manipulation Examples • LA Times photographer Brian Walski makes an image more dramatic (2003) – He was fired two days later More info: www.sree.net/teaching/lateditors.html; www.washingtonpost.com/wp-srv/photo/essays/vanRiper/030409.htm Walski responds: www.pdnonline.com/pdn/search/article_display.jsp?vnu_content_id=1000456607 52 Some Image Manipulation Examples • Modification of images in the news media – National Guard fires on student protesters at Kent State University in May, 1970, killing 4 students • Original O i i l Pulitzer-prize P lit i winning i i news photograph h t h • vs. version used later in Life and other publications en.wikipedia.org/wiki/Kent_State_shootings; journalism_jobs.tripod.com/a.filo.html 53 Some Image Manipulation Examples • June 1994: O. J. Simpson arrested for murder – Time and Newsweek both used the police mug shot on their covers – Appeared side-by-side on newsstands – Newsweek took it straight; but Time altered their version – Time later defended this by claiming it wasn’t a “news photo” but rather a “photo illustration” 54 18 Some Image Manipulation Examples • But, Newsweek can be guilty too guilty, • The McCaughey septuplets (1997) 55 Some Image Manipulation Examples • Politics: John Kerry and Jane Fonda www.snopes.com/photos/politics/kerry2.asp 56 Some Image Manipulation Examples • Politics: George W. Bush www.snopes.com/photos/bushbook.asp 57 19 Image Manipulation • Because images may be manipulated so easily, we must critically evaluate the images that we see – When an image is changed, is it a deception, or a clarification? – Our universe is only what we experience directly – and much of that has been presented to us by someone else 58 Ethics of Image Modification • Suggested ethical guidelines for image use by news outlets – – – www.digitalcustom.com/howto/mediaguidelines.asp www.nppa.org/professional_development/business_practices/ethics.html www.nppa.org/professional_development/business_practices/ethicsdefault.html • Credibility - some questions to ask – Is the photograph a Fair and Accurate Representation of the info being presented? – In what Context is the photo being used? – Does this photograph Deceive the reader? • A few other resources snopes.com —probably the best place to check email and Web scams, hoaxes, etc. – “Digital Tempering in the Media, Politics and Law.” Hany Farid. Dartmouth College. www.cs.dartmouth.edu/farid/research/digitaltampering • Farid, Hany. “Digital Doctoring: How to Tell the Real From the Fake.” – Leach, Susan L. “Seeing is No Longer Believing.” The Christian Science Monitor, 2 Feb. 2005, p. 15. – 59 20