cameras and images
play

Cameras and Images Sanja Fidler Intro to Image Understanding 1 / - PowerPoint PPT Presentation

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


  1. Example What’s the result? #" #" #" !" !" !" %" - ! * #" $" #" !" !" !" #" #" #" !" !" !" Original ! [Source: D. Lowe] Sanja Fidler Intro to Image Understanding 27 / 57

  2. Example What’s the result? #" #" #" !" !" !" 0" - ! * #" $" #" !" !" !" #" #" #" !" !" !" !"#$%&'(')*+,-&$* Original ! %&''()*+&*(,"(-.(,/ * [Source: D. Lowe] Sanja Fidler Intro to Image Understanding 27 / 57

  3. Sharpening [Source: D. Lowe] Sanja Fidler Intro to Image Understanding 28 / 57

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

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

  6. 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 Intro to Image Understanding 31 / 57

  7. Smoothing with a Gaussian [Source: K. Grauman] Sanja Fidler Intro to Image Understanding 32 / 57

  8. Mean vs Gaussian Sanja Fidler Intro to Image Understanding 33 / 57

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

  10. Gaussian filter: Parameters Variance of the Gaussian : determines extent of smoothing. [Source: K. Grauman] Sanja Fidler Intro to Image Understanding 35 / 57

  11. Gaussian filter: Parameters [Source: K. Grauman] Sanja Fidler Intro to Image Understanding 36 / 57

  12. 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 use for filtering. Sanja Fidler Intro to Image Understanding 37 / 57

  13. Properties of the Smoothing All values are positive. They all sum to 1. Sanja Fidler Intro to Image Understanding 38 / 57

  14. Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Sanja Fidler Intro to Image Understanding 38 / 57

  15. 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 Intro to Image Understanding 38 / 57

  16. 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 Intro to Image Understanding 38 / 57

  17. Finding Waldo filter F image I Let’s do normalized cross-correlation Sanja Fidler Intro to Image Understanding 39 / 57

  18. Finding Waldo Result Sanja Fidler Intro to Image Understanding 39 / 57

  19. Finding Waldo Result Sanja Fidler Intro to Image Understanding 39 / 57

  20. Finding Waldo Voila! Homework : Do it yourself! Code on class webpage. Don’t cheat ;) Sanja Fidler Intro to Image Understanding 39 / 57

  21. 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 Intro to Image Understanding 40 / 57

  22. Convolution Convolution operator k k � � F ( u , v ) · I ( i − u , j − v ) G ( i , j ) = u = − k v = − k Equivalent to flipping the filter in both dimensions (bottom to top, right to left) and apply correlation. If filter is symmetric , then correlation and convolution are the same Sanja Fidler Intro to Image Understanding 40 / 57

  23. Convolution Convolution operator k k � � F ( u , v ) · I ( i − u , j − v ) G ( i , j ) = u = − k v = − k Equivalent to flipping the filter in both dimensions (bottom to top, right to left) and apply correlation. If filter is symmetric , then correlation and convolution are the same Sanja Fidler Intro to Image Understanding 40 / 57

  24. Correlation vs Convolution For a Gaussian or box filter, how will the outputs differ? If the input is an impulse signal, how will the outputs differ? δ ∗ I ?, and δ ⊗ I ? Sanja Fidler Intro to Image Understanding 41 / 57

  25. ”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 Intro to Image Understanding 42 / 57

  26. 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 Intro to Image Understanding 43 / 57

  27. 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 Intro to Image Understanding 43 / 57

  28. 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 Intro to Image Understanding 43 / 57

  29. 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 Intro to Image Understanding 44 / 57

  30. 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 Intro to Image Understanding 45 / 57

  31. 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 Intro to Image Understanding 45 / 57

  32. 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 Intro to Image Understanding 46 / 57

  33. 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 Intro to Image Understanding 46 / 57

  34. 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 Intro to Image Understanding 46 / 57

  35. 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 Intro to Image Understanding 46 / 57

  36. 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 Intro to Image Understanding 47 / 57

  37. 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 Intro to Image Understanding 47 / 57

  38. 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 Intro to Image Understanding 47 / 57

  39. 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 . And it is the outer product of two filters: F = v h T Homework: Think why in the case of separable filters 2D convolution is the same as two 1D convolutions [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 47 / 57

  40. 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 . And it is the outer product of two filters: F = v h T Homework: Think why in the case of separable filters 2D convolution is the same as two 1D convolutions [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 47 / 57

  41. How it Works Sanja Fidler Intro to Image Understanding 48 / 57

  42. How it Works Sanja Fidler Intro to Image Understanding 48 / 57

  43. How it Works Sanja Fidler Intro to Image Understanding 48 / 57

  44. How it Works Sanja Fidler Intro to Image Understanding 48 / 57

  45. Separable Filters: Gaussian filters One famous separable filter we already know: 2 πσ 2 e − x 2+ y 2 1 Gaussian : f ( x , y ) = σ 2 2 πσ e − x 2 2 πσ e − y 2 1 1 � σ 2 � � σ 2 � = · √ √ Sanja Fidler Intro to Image Understanding 49 / 57

  46. Let’s play a game... Is this separable? If yes, what’s the separable version? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 50 / 57

  47. Let’s play a game... Is this separable? If yes, what’s the separable version? What does this filter do? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 50 / 57

  48. Let’s play a game... Is this separable? If yes, what’s the separable version? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 51 / 57

  49. Let’s play a game... Is this separable? If yes, what’s the separable version? What does this filter do? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 51 / 57

  50. Let’s play a game... Is this separable? If yes, what’s the separable version? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 52 / 57

  51. Let’s play a game... Is this separable? If yes, what’s the separable version? What does this filter do? [Source: R. Urtasun] Sanja Fidler Intro to Image Understanding 52 / 57

  52. How can we tell if a given filter F is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Sanja Fidler Intro to Image Understanding 53 / 57

  53. How can we tell if a given filter F is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Look at the singular value decomposition (SVD) , and if only one singular value is non-zero, then it is separable F = U Σ V T = � σ i u i v T i i with Σ = diag( σ i ). Sanja Fidler Intro to Image Understanding 53 / 57

  54. How can we tell if a given filter F is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Look at the singular value decomposition (SVD) , and if only one singular value is non-zero, then it is separable F = U Σ V T = � σ i u i v T i i with Σ = diag( σ i ). Matlab: [U,S,V] = svd(F); Sanja Fidler Intro to Image Understanding 53 / 57

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