Lecture 10: Modifying Images - University of...

24
Lecture 10: Modifying Images The Digital World of Multimedia Prof. Mari Ostendorf

Transcript of Lecture 10: Modifying Images - University of...

Page 1: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

Lecture 10: Modifying Images

The Digital World of MultimediaProf. Mari Ostendorf

Page 2: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

AnnouncementsHW3 due Friday in classGuest lecture Friday Feb 1 (EEB 403)

A cultural history of JPEG… Dr. Joan MitchellAnother lecture by Dr. Mitchell on Thurs

Patenting a wet suit… Thurs 1/31 10:30 EEB 125Lab3: Read the lab *before* lab

Page 3: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Goals for TodayReview of frequency content of imagesSampling and aliasing for imagesAnalogies in sound vs. image processingImage filtering

Page 4: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Simple Cosines in Space

Page 5: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

2D Frequency Content of Images

DCT = Discrete Cosine Transform

Page 6: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Display Artifacts of the DCT (and DFT)

F=100300ppi

F=160480ppi

F=200600ppi

Page 7: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Aliasing for Images

F=50 for cosine, 300ppi original

Page 8: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Aliasing for Images (cont)Highest frequencies in center aliasingRegion of aliasing grows with downsampling

This is aliasing, not zooming in.

Page 9: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Another Aliasing Example

For more interesting examples, see Orsak et al. pp. 133-134

Page 10: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Sound vs. Image SP AnalogiesSound

Time-scalingAmplitude scaling: change loudnessEchoTime reverseFilter:

LPF: smoothing, sounds more muffledHPF: detect onsets, sounds more tinny

ImageExpand/shrink imageAmplitude scaling: change brightnessDouble exposureImage flipFilter

LPF: blurring, speckle removalHPF: deblurring, edge detection

Page 11: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Resizing ImagesShrinking:

Grayscale: replace KxK block with single pixel with average gray level of the K2 pixels in the originalColor: Repeat for each color plane

Enlarging:Grayscale: insert interpolated pixel valuesColor: repeat for each color plane, as in shrinking

Page 12: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

+90

-90

Amplitude Scaling for Images

Page 13: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Review: Grayscale vs. ColorGray: MxN matrix Color: MxNx3

B/W intensity:• 0 = black• 1 = white

X(i,j)=0.4

X(i,j,2)=0.6 X(i,j,3)=1.0

R/G/B intensity:• [0,1]=[none, full]• (0,0,0)=black• (1,1,1)=white

X(i,j,1)=0.75

8 bits/pixel 256 gray levels

8 bits/color-pixel 2563 colors,

24 bits/pixel

Page 14: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Color Digital ImagesComponent colors

Page 15: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Adjusting Amplitude in Color Images

par=min(255,par+100);

par(:,:,2)=min(255,par(:,:,2)+100);

More of all colors more white

More green

Page 16: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Changing Color Images (cont.)

Turning off a color:X(:,:,1)=0;

Page 17: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Swapping Color Planes

Swap:G RB GR B

original

Page 18: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Reminder of Time Signal Filtering

original

low pass filtered(15 sample average)

high pass filtered(avg of 5 samples – avg of next 5 samples)

Page 19: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Image Filtering

original

2D low pass filtered(average over 15x15 block) 2D high pass filtered1D high pass filtered

Using the same filters as in the previous slide, but in 2D, e.g.

filt2d=filt*filt’

Page 20: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

More Filtering Examples

original 2D low pass filtered 2D high pass filtered

Page 21: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Another Example

filteredoriginal

What type of filter was used?

Page 22: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Modifying Color Images

original

Blur only the green plane

Blur everything

Each color plane can be manipulated as a grayscale image, e.g. filtered, contrast enhanced, etc.

Page 23: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

NEW TOPIC: COMPRESSIONWhat is compression?

Representing an signal (sound file, image or video) with fewer total bits

Why bother?Storage: You can fit more songs & videos on your IPODCommunication: It takes less time to download stuff; real-time video conferencing

Page 24: Lecture 10: Modifying Images - University of Washingtonssli.ee.washington.edu/courses/ee299/notes/lecture10.pdf30 Jan 2008 EE299 Lecture 10 Announcements HW3 due Friday in class Guest

EE299 Lecture 1030 Jan 2008

Types of CompressionLossless

Represent the sound/image/video with fewer bits without changing the signal *at all* (you can perfectly reconstruct the original)How? (like the 20 questions game)

Map the different levels to a variable-length code, using short codes for more frequent things

LossyRepresent the sound/image/video with fewer bits with some changes from the originalHow?

Throw out the stuff that people don’t pay attention to