cameras and images
play

Cameras and Images Sanja Fidler CSC420: Intro to Image - PowerPoint PPT Presentation

Cameras and Images Sanja Fidler CSC420: Intro to Image Understanding 1 / 58 Pinhole Camera [Source: A. Torralba] Make your own camera http://www.foundphotography.com/PhotoThoughts/archives/2005/ 04/pinhole_camera_2.html Sanja Fidler


  1. Linear Filtering: Correlation Involves weighted combinations of pixels in small neighborhoods: k k 1 � � G ( i , j ) = I ( i + u , j + v ) (2 k + 1) 2 u = − k v = − k The output pixels value is determined as a weighted sum of input pixel values k k � � F ( u , v ) · I ( i + u , j + v ) G ( i , j ) = u = − k v = − k The entries of the weight kernel or mask F ( u , v ) are often called the filter coefficients . This operator is the correlation operator G = F ⊗ I Sanja Fidler CSC420: Intro to Image Understanding 25 / 58

  2. Linear Filtering: Correlation It’s really easy! Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

  3. Linear Filtering: Correlation It’s really easy! Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

  4. Linear Filtering: Correlation It’s really easy! Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

  5. Linear Filtering: Correlation It’s really easy! k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

  6. Linear Filtering: Correlation What happens along the borders of the image? k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

  7. Boundary Effects What happens at the border of the image? What’s the size of the output matrix? MATLAB: filter2(g, f, shape) shape = “full” output size is sum of sizes of f and g shape = “same”: output size is same as f shape = “valid”: output size is difference of sizes of f and g [Source: S. Lazebnik] Sanja Fidler CSC420: Intro to Image Understanding 27 / 58

  8. Boundary Effects What happens at the border of the image? What’s the size of the output matrix? MATLAB: filter2(g, f, shape) shape = “full” output size is sum of sizes of f and g shape = “same”: output size is same as f shape = “valid”: output size is difference of sizes of f and g [Source: S. Lazebnik] Sanja Fidler CSC420: Intro to Image Understanding 27 / 58

  9. Filtering with Correlation: Example What’s the result? [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  10. Filtering with Correlation: Example What’s the result? [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  11. Filtering with Correlation: Example What’s the result? [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  12. Filtering with Correlation: Example What’s the result? [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  13. Filtering with Correlation: Example What’s the result? #" #" #" !" !" !" %" - ! * #" $" #" !" !" !" #" #" #" !" !" !" Original ! [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  14. Filtering with Correlation: Example What’s the result? #" #" #" !" !" !" 0" - ! * #" $" #" !" !" !" #" #" #" !" !" !" !"#$%&'(')*+,-&$* Original ! %&''()*+&*(,"(-.(,/ * [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

  15. Sharpening [Source: D. Lowe] Sanja Fidler CSC420: Intro to Image Understanding 29 / 58

  16. Sharpening !"#$%&'&() #$%&'&() [Source: N. Snavely] Sanja Fidler CSC420: Intro to Image Understanding 30 / 58

  17. Example of Correlation What is the result of filtering the impulse signal (image) I with the arbitrary filter F? [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 31 / 58

  18. Smoothing by averaging What if the filter size was 5 x 5 instead of 3 x 3? [Source: K. Graumann] Sanja Fidler CSC420: Intro to Image Understanding 32 / 58

  19. Gaussian filter What if we want nearest neighboring pixels to have the most influence on the output? Removes high-frequency components from the image (low-pass filter). [Source: S. Seitz] Sanja Fidler CSC420: Intro to Image Understanding 33 / 58

  20. Smoothing with a Gaussian [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 34 / 58

  21. Mean vs Gaussian Sanja Fidler CSC420: Intro to Image Understanding 35 / 58

  22. Gaussian filter: Parameters Size of filter or mask : Gaussian function has infinite support, but discrete filters use finite kernels. [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 36 / 58

  23. Gaussian filter: Parameters Variance of the Gaussian : determines extent of smoothing. [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 37 / 58

  24. Gaussian filter: Parameters [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 38 / 58

  25. Is this the most general Gaussian? No, the most general form for x ∈ ℜ d 1 � − 1 � 2( x − µ ) T Σ − 1 ( x − µ ) N ( x ; µ, Σ) = (2 π ) d / 2 | Σ | 1 / 2 exp But the simplified version is typically used for filtering. Sanja Fidler CSC420: Intro to Image Understanding 39 / 58

  26. Properties of the Smoothing All values are positive. They all sum to 1. Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

  27. Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

  28. Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Remove high-frequency components; low-pass filter. Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

  29. Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Remove high-frequency components; low-pass filter. Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

  30. Finding Waldo image I How can we use what we just learned to find Waldo? Sanja Fidler CSC420: Intro to Image Understanding 41 / 58

  31. Finding Waldo filter F image I Is correlation a good choice? Sanja Fidler CSC420: Intro to Image Understanding 41 / 58

  32. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Can we write that in a more compact form (with vectors)? Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  33. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  34. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  35. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  36. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Can we write that in a more compact form (with vectors)? Define f = F (:), T ij = I ( i − k : i + k , j − k : j + k ), and t ij = T ij (:) G ( i , j ) = f T · t ij where · is a dot product Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  37. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Can we write that in a more compact form (with vectors)? Define f = F (:), T ij = I ( i − k : i + k , j − k : j + k ), and t ij = T ij (:) G ( i , j ) = f T · t ij where · is a dot product Homework: Can we write full correlation G = F ⊗ I in matrix form? Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  38. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Can we write that in a more compact form (with vectors)? Define f = F (:), T ij = I ( i − k : i + k , j − k : j + k ), and t ij = T ij (:) G ( i , j ) = f T · t ij where · is a dot product Finding Waldo: How could we ensure to get the best “score” (e.g. 1) for an image crop that looks exactly like our filter? Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  39. A Slight Detour: Correlation in Matrix Form Remember correlation: k k � � G ( i , j ) = F ( u , v ) · I ( i + u , j + v ) u = − k v = − k Can we write that in a more compact form (with vectors)? Define f = F (:), T ij = I ( i − k : i + k , j − k : j + k ), and t ij = T ij (:) G ( i , j ) = f T · t ij where · is a dot product Finding Waldo: How could we ensure to get the best “score” (e.g. 1) for an image crop that looks exactly like our filter? Normalized cross-correlation: f T · t ij G ( i , j ) = || f || · || t ij || Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

  40. Back to Waldo filter F image I Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

  41. Back to Waldo Result of normalized cross-correlation Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

  42. Back to Waldo Find the highest peak Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

  43. Back to Waldo And put a bounding box (rectangle the size of the template) at the point! Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

  44. Back to Waldo Homework : Do it yourself! Code on class webpage. Don’t cheat ;) Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

  45. Convolution Convolution operator k k � � G ( i , j ) = F ( u , v ) · I ( i − u , j − v ) u = − k v = − k Sanja Fidler CSC420: Intro to Image Understanding 44 / 58

  46. Convolution Convolution operator k k � � G ( i , j ) = F ( u , v ) · I ( i − u , j − v ) u = − k v = − k Equivalent to flipping the filter in both dimensions (bottom to top, right to left) and apply correlation. Sanja Fidler CSC420: Intro to Image Understanding 44 / 58

  47. Correlation vs Convolution = Correlation Convolution Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

  48. Correlation vs Convolution For a Gaussian or box filter, how will the outputs F ∗ I and F ⊗ I differ? Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

  49. Correlation vs Convolution For a Gaussian or box filter, how will the outputs F ∗ I and F ⊗ I differ? How will the outputs differ for:   0 0 0 0 0 1     0 0 0 Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

  50. Correlation vs Convolution For a Gaussian or box filter, how will the outputs F ∗ I and F ⊗ I differ? How will the outputs differ for:   0 0 0 0 0 1     0 0 0 If the input is an impulse signal, how will the outputs differ? δ ∗ I and δ ⊗ I ? Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

  51. ”Optical” Convolution Camera Shake !" * Figure: Fergus, et al., SIGGRAPH 2006 Blur in out-of-focus regions of an image. Figure: Bokeh: http://lullaby.homepage.dk/diy-camera/bokeh.html Click for more info [Source: N. Snavely] Sanja Fidler CSC420: Intro to Image Understanding 46 / 58

  52. Properties of Convolution Commutative : f ∗ g = g ∗ f Associative : f ∗ ( g ∗ h ) = ( f ∗ g ) ∗ h Distributive : f ∗ ( g + h ) = f ∗ g + f ∗ h Assoc. with scalar multiplier : λ · ( f ∗ g ) = ( λ · f ) ∗ h Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

  53. Properties of Convolution Commutative : f ∗ g = g ∗ f Associative : f ∗ ( g ∗ h ) = ( f ∗ g ) ∗ h Distributive : f ∗ ( g + h ) = f ∗ g + f ∗ h Assoc. with scalar multiplier : λ · ( f ∗ g ) = ( λ · f ) ∗ h The Fourier transform of two convolved images is the product of their individual Fourier transforms: F ( f ∗ g ) = F ( f ) · F ( g ) Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

  54. Properties of Convolution Commutative : f ∗ g = g ∗ f Associative : f ∗ ( g ∗ h ) = ( f ∗ g ) ∗ h Distributive : f ∗ ( g + h ) = f ∗ g + f ∗ h Assoc. with scalar multiplier : λ · ( f ∗ g ) = ( λ · f ) ∗ h The Fourier transform of two convolved images is the product of their individual Fourier transforms: F ( f ∗ g ) = F ( f ) · F ( g ) Homework: Why is this good news? Hint: Think of complexity of convolution and Fourier Transform Both correlation and convolution are linear shift-invariant (LSI) operators : the effect of the operator is the same everywhere. Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

  55. Gaussian Filter Convolution with itself is another Gaussian !" * Convolving twice with Gaussian kernel of width σ is the same as √ convolving once with kernel of width σ 2 We don’t need to filter twice, just once with a bigger kernel [Source: K. Grauman] Sanja Fidler CSC420: Intro to Image Understanding 48 / 58

  56. Separable Filters: Speed-up Trick! The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution filter. Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

  57. Separable Filters: Speed-up Trick! The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution filter. Can we do faster? Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

  58. Separable Filters: Speed-up Trick! The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution filter. Can we do faster? In many cases ( not all! ), this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring only 2 K operations . Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

  59. Separable Filters: Speed-up Trick! The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution filter. Can we do faster? In many cases ( not all! ), this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring only 2 K operations . If this is possible, then the convolution filter is called separable . Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend