1 / 68

CS559: Computer Graphics

CS559: Computer Graphics. Lecture 6: Edge Detection, Image Compositing, and Warping Li Zhang Spring 2010. Last time: Image Resampling and Painterly Rendering. Last time: Image Resampling and Painterly Rendering. Properties of Kernels.

Download Presentation

CS559: Computer Graphics

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. CS559: Computer Graphics Lecture 6: Edge Detection, Image Compositing, and Warping Li Zhang Spring 2010

  2. Last time: Image Resampling and Painterly Rendering

  3. Last time: Image Resampling and Painterly Rendering

  4. Properties of Kernels • Filter, Impulse Response, or kernel function, same concept but different names • Degrees of continuity • Interpolating or no • Ringing or overshooting Interpolating filter for reconstruction

  5. Reconstruction filter Examples in 2D 2D example: g[n+1,m] g[n,m] (x,y) g[n+1,m+1] g[n,m+1] How to simplify the calculation?

  6. Image Downsampling 1/8 1/4 • Throw away every other row and column to create a 1/2 size image • - called image sub-sampling

  7. Image sub-sampling 1/2 1/4 (2x zoom) 1/8 (4x zoom) Why does this look so crufty? Minimum Sampling requirement is not satisfied – resulting in Aliasing effect

  8. Subsampling with Gaussian pre-filtering Gaussian 1/2 G 1/4 G 1/8 • Solution: filter the image, then subsample

  9. Results in the paper Original Biggest brush Medium brush added Finest brush added

  10. Changing Parameters

  11. Changing Parameters Impressionist, normal painting style Expressionist, elongated stroke Colorist wash, semitransparent stroke with color jitter Densely-placed circles with random hue and saturation

  12. Another type of painterly rendering • Line Drawing http://www.cs.rutgers.edu/~decarlo/abstract.html

  13. Another type of painterly rendering • Line Drawing http://www.cs.rutgers.edu/~decarlo/abstract.html

  14. Another type of painterly rendering • Line Drawing http://www.cs.rutgers.edu/~decarlo/abstract.html

  15. Another type of painterly rendering • Line Drawing http://www.cs.rutgers.edu/~decarlo/abstract.html

  16. Edge Detection • Convert a 2D image into a set of curves • Extracts salient features of the scene

  17. Edge detection • One of the most important uses of image processing is edge detection: • Really easy for humans • Not that easy for computers • Fundamental in computer vision • Important in many graphics applications

  18. What is an edge? • Q: How might you detect an edge in 1D?

  19. Image gradient • The gradient of an image: • The gradient points in the direction of most rapid change in intensity • The gradient direction is given by: • how does the gradient relate to the direction of the edge? • The edge strength is given by the gradient magnitude

  20. Gradients • How can we approximate the gradient in a discrete image? gx[i,j] = f[i+1,j] – f[i,j] and gy[i,j]=f[i,j+1]-f[i,j] Can write as mask [-1 1] and [1 –1]’

  21. Less than ideal edges

  22. Results of Sobel edge detection

  23. Edge enhancement • A popular gradient magnitude computation is the Sobel operator: • We can then compute the magnitude of the vector (sx, sy).

  24. Results of Sobel edge detection

  25. Results of Sobel edge detection

  26. Non-maximum Suppression • Check if pixel is local maximum along gradient direction • requires checking interpolated pixels p and r The Canny Edge Detector

  27. Steps in edge detection • Edge detection algorithms typically proceed in three or four steps: • Filtering: cut down on noise • Enhancement: amplify the difference between edges and non-edges • Detection: use a threshold operation • Localization (optional): estimate geometry of edges, which generally pass between pixels

  28. The Canny Edge Detector original image (Lena)

  29. The Canny Edge Detector magnitude of the gradient

  30. The Canny Edge Detector After non-maximum suppression

  31. Canny Edge Detector original Canny with Canny with : Gaussian filter parameter • The choice of depends on desired behavior • large detects large scale edges • small detects fine features

  32. Compositing • Compositing combines components from two or more images to make a new image • Special effects are easier to control when done in isolation • Even many all live-action sequences are more safely shot in different layers

  33. Compositing • Compositing combines components from two or more images to make a new image • Special effects are easier to control when done in isolation • Even many all live-action sequences are more safely shot in different layers

  34. Perfect Storm

  35. Animated Example = over

  36. Mattes • A matte is an image that shows which parts of another image are foreground objects • Term dates from film editing and cartoon production • How would I use a matte to insert an object into a background? • How are mattes usually generated for television?

  37. Working with Mattes • To insert an object into a background • Call the image of the object the source • Put the background into the destination • For all the source pixels, if the matte is white, copy the pixel, otherwise leave it unchanged

  38. Working with Mattes • To insert an object into a background • Call the image of the object the source • Put the background into the destination • For all the source pixels, if the matte is white, copy the pixel, otherwise leave it unchanged • To generate mattes: • Use smart selection tools in Photoshop or similar • They outline the object and convert the outline to a matte • Blue Screen: Photograph/film the object in front of a blue background, then consider all the blue pixels in the image to be the background

  39. Compositing • Compositing is the term for combining images, one over the other • Used to put special effects into live action • Or live action into special effects

  40. Alpha • Basic idea: Encode opacity information in the image • Add an extra channel, the alpha channel, to each image • For each pixel, store R, G, B and Alpha • alpha = 1 implies full opacity at a pixel • alpha = 0 implies completely clear pixels • Images are now in RGBA format, and typically 32 bits per pixel (8 bits for alpha) • All images in the project are in this format

  41. Pre-Multiplied Alpha • Instead of storing (R,G,B,), store (R,G,B,) • The compositing operations in the next several slides are easier with pre-multiplied alpha • To display and do color conversions, must extract RGB by dividing out  • =0 is always black • Some loss of precision as  gets small, but generally not a big problem

  42. Why do we need pre-multiplied alpha? “Over” Operator

  43. Why do we need pre-multiplied alpha? “Over” Operator

  44. Why do we need pre-multiplied alpha? “Over” Operator

  45. Why do we need pre-multiplied alpha? “Over” Operator

  46. Why do we need pre-multiplied alpha? “Over” Operator

  47. Why do we need pre-multiplied alpha? “Over” Operator

More Related