lecture 8 image filtering ii
play

Lecture 8: Image Filtering II Justin Johnson EECS 442 WI 2020: - PowerPoint PPT Presentation

Lecture 8: Image Filtering II Justin Johnson EECS 442 WI 2020: Lecture 8 - 1 February 4, 2020 Administrative HW1 is due Tomorrow, Wednesday 2/5 11:59pm HW2 should be released tomorrow, due Wednesday 2/19 11:59pm Justin Johnson EECS 442 WI


  1. Lecture 8: Image Filtering II Justin Johnson EECS 442 WI 2020: Lecture 8 - 1 February 4, 2020

  2. Administrative HW1 is due Tomorrow, Wednesday 2/5 11:59pm HW2 should be released tomorrow, due Wednesday 2/19 11:59pm Justin Johnson EECS 442 WI 2020: Lecture 8 - 2 February 4, 2020

  3. Last Time: Image Filtering Input Filter Output I11 I12 I13 I14 I15 I16 F11 F12 F13 O11 O12 O13 O14 I21 I22 I23 I24 I25 I26 I31 I32 I33 I34 I35 I36 F21 F22 F23 O21 O22 O23 O24 F31 F32 F33 O31 O32 O33 O34 I41 I42 I43 I44 I45 I46 I51 I52 I53 I54 I55 I56 Justin Johnson EECS 442 WI 2020: Lecture 8 - 3 February 4, 2020

  4. Last Time: Image Filtering 0 1 0 0 0 0 0 0 0 Original Shifted DOWN 1 pixel Slide Credit: D. Lowe Justin Johnson EECS 442 WI 2020: Lecture 8 - 4 February 4, 2020

  5. Last Time: Image Filtering 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 Original Blur (Box Filter) Slide Credit: D. Lowe Justin Johnson EECS 442 WI 2020: Lecture 8 - 5 February 4, 2020

  6. Last Time: Image Filtering 0 0 0 0 2 0 0 0 0 - 1/9 1/9 1/9 Original Sharpened (Acccentuates 1/9 1/9 1/9 difference from local average) 1/9 1/9 1/9 Slide Credit: D. Lowe Justin Johnson EECS 442 WI 2020: Lecture 8 - 6 February 4, 2020

  7. Last Time: Convolution • Linear: f(aI + bI’) = af(I) + bf(I’) • Shift-Invariant: shift(f(I)) = f(shift(I)) • Any shift-invariant, linear operation is a convolution ( ⁎ ) • Commutative: f ⁎ g = g ⁎ f • Associative: (f ⁎ g) ⁎ h = f ⁎ (g ⁎ h) • Distributes over +: f ⁎ (g + h) = f ⁎ g + f ⁎ h • Scalars factor out: kf ⁎ g = f ⁎ kg = k (f ⁎ g) • Identity (a single one with all zeros): * = Property List: K. Grauman Justin Johnson EECS 442 WI 2020: Lecture 8 - 7 February 4, 2020

  8. Today: Applications of Linear Filters Justin Johnson EECS 442 WI 2020: Lecture 8 - 8 February 4, 2020

  9. Box Smoothing Intuition: if filter touches it, it gets a contribution. Input Box Filter Problem: “Boxy” artifacts Justin Johnson EECS 442 WI 2020: Lecture 8 - 9 February 4, 2020

  10. Solution: Per-Pixel Weights Intuition: weight contributions according to closeness to center. Box Smoothing: 𝐺𝑗𝑚𝑢𝑓𝑠 '( ∝ 1 What’s this? Better Approach: '( ∝ exp − 𝑦 0 + 𝑧 0 𝐺𝑗𝑚𝑢𝑓𝑠 2𝜏 0 Justin Johnson EECS 442 WI 2020: Lecture 8 - 10 February 4, 2020

  11. Recognize the Filter? It’s a Gaussian! 2𝜌𝜏 0 exp − 𝑦 0 + 𝑧 0 1 𝐺𝑗𝑚𝑢𝑓𝑠 '( ∝ 2𝜏 0 0.003 0.013 0.022 0.013 0.003 0.013 0.060 0.098 0.060 0.013 0.022 0.098 0.162 0.098 0.022 0.013 0.060 0.098 0.060 0.013 0.003 0.013 0.022 0.013 0.003 Justin Johnson EECS 442 WI 2020: Lecture 8 - 11 February 4, 2020

  12. Box Blur vs Gaussian Blur Still have some speckles, but it’s not a big box Input Box Filter Gauss. Filter Justin Johnson EECS 442 WI 2020: Lecture 8 - 12 February 4, 2020

  13. Gaussian Filters σ = 1 σ = 2 σ = 4 σ = 8 filter = 21x21 filter = 21x21 filter = 21x21 filter = 21x21 Note: filter visualizations are independently normalized throughout the slides so you can see them better Justin Johnson EECS 442 WI 2020: Lecture 8 - 13 February 4, 2020

  14. Applying Gaussian Filters Justin Johnson EECS 442 WI 2020: Lecture 8 - 14 February 4, 2020

  15. Applying Gaussian Filters Input Image (no filter) Justin Johnson EECS 442 WI 2020: Lecture 8 - 15 February 4, 2020

  16. Applying Gaussian Filters σ = 1 Justin Johnson EECS 442 WI 2020: Lecture 8 - 16 February 4, 2020

  17. Applying Gaussian Filters σ = 2 Justin Johnson EECS 442 WI 2020: Lecture 8 - 17 February 4, 2020

  18. Applying Gaussian Filters σ = 4 Justin Johnson EECS 442 WI 2020: Lecture 8 - 18 February 4, 2020

  19. Applying Gaussian Filters σ = 8 Justin Johnson EECS 442 WI 2020: Lecture 8 - 19 February 4, 2020

  20. Gaussian Blur: Filter Size Too small filter → bad approximation Want size ≈ 6σ (99.7% of energy) Left far too small; right slightly too small! σ = 8, size = 21 σ = 8, size = 43 Justin Johnson EECS 442 WI 2020: Lecture 8 - 20 February 4, 2020

  21. Runtime Complexity Image size = NxN = 6x6 Filter size = MxM = 3x3 for ImageY in range(N): I11 I12 I13 I14 I15 I16 for ImageX in range(N): I21 F11 I22 F12 I23 F13 I24 I25 I26 for FilterY in range(M): I31 F21 I32 F22 I33 F23 I34 I35 I36 for FilterX in range(M): F31 F32 F33 I41 I42 I43 I44 I45 I46 … I51 I52 I53 I54 I55 I56 Time: O(N 2 M 2 ) I61 I62 I63 I64 I65 I66 Justin Johnson EECS 442 WI 2020: Lecture 8 - 21 February 4, 2020

  22. Separable Filters Conv(vector, transposed vector) → outer product Fx1 * Fx2 * Fx3 * Fy1 Fy1 Fy1 Fy1 ⁎ = Fx1 * Fx2 * Fx3 * Fy2 Fx1 Fx2 Fx3 Fy2 Fy2 Fy2 Fx1 * Fx2 * Fx3 * Fy3 Fy3 Fy3 Fy3 (Using “full” convolution with zero padding) (Also ignoring filter flips) Justin Johnson EECS 442 WI 2020: Lecture 8 - 22 February 4, 2020

  23. Separable Filters: Gaussian 2𝜌𝜏 0 exp − 𝑦 0 + 𝑧 0 1 𝐺𝑗𝑚𝑢𝑓𝑠 '( ∝ 2𝜏 0 → exp − 𝑦 0 exp − 𝑧 0 1 1 𝐺𝑗𝑚𝑢𝑓𝑠 '( ∝ 2𝜏 0 2𝜏 0 2𝜌𝜏 2𝜌𝜏 Justin Johnson EECS 442 WI 2020: Lecture 8 - 23 February 4, 2020

  24. Separable Filters: Gaussian 1D Gaussian ⁎ 1D Gaussian = 2D Gaussian Image ⁎ 2D Gauss = Image ⁎ (1D Gauss ⁎ 1D Gauss ) = (Image ⁎ 1D Gauss) ⁎ 1D Gauss ⁎ = Justin Johnson EECS 442 WI 2020: Lecture 8 - 24 February 4, 2020

  25. Separable Filters: Runtime Complexity Image size = NxN = 6x6 Filter size = Mx1 = 3x1 for ImageY in range(N): I11 I12 I13 I14 I15 I16 for ImageX in range(N): I21 I22 F1 I23 I24 I25 I26 for FilterY in range(M): I31 I32 F2 I33 I34 I35 I36 … F3 I41 I42 I43 I44 I45 I46 for ImageY in range(N): for ImageX in range(N): I51 I52 I53 I54 I55 I56 for FilterX in range(M): I61 I62 I63 I64 I65 I66 … What are my compute savings for a 13x13 filter? Time: O(N 2 M) Justin Johnson EECS 442 WI 2020: Lecture 8 - 25 February 4, 2020

  26. Why Gaussian? Gaussian filtering removes parts of the signal above a certain frequency. Often noise is high frequency and signal is low frequency. Justin Johnson EECS 442 WI 2020: Lecture 8 - 26 February 4, 2020

  27. Where Gaussian Fails Justin Johnson EECS 442 WI 2020: Lecture 8 - 28 February 4, 2020

  28. Where Gaussian Fails σ = 1 Justin Johnson EECS 442 WI 2020: Lecture 8 - 29 February 4, 2020

  29. Where Gaussian Fails Means can be arbitrarily distorted by outliers Signal 10 12 9 8 1000 11 10 12 Filter 0.1 0.8 0.1 Output 11.5 9.2 107.3 801.9 109.8 10.3 What else is an “average” other than a mean? Justin Johnson EECS 442 WI 2020: Lecture 8 - 30 February 4, 2020

  30. Median Filter [040, 081, 013, 125, 830, 076, 144, 092, 108] Sort 40 81 13 22 [013, 040, 076, 081, 092, 108, 125, 144, 830] 125 830 76 80 144 92 108 95 92 132 102 106 87 [830, 076, 080, 092, 108, 095, 102, 106, 087] Sort [076, 080, 087, 092, 095, 102, 106, 108, 830] 95 Justin Johnson EECS 442 WI 2020: Lecture 8 - 31 February 4, 2020

  31. Median Filter Median Filter (size=3) Justin Johnson EECS 442 WI 2020: Lecture 8 - 32 February 4, 2020

  32. Median Filter Median Filter (size = 7) Justin Johnson EECS 442 WI 2020: Lecture 8 - 33 February 4, 2020

  33. Is Median Filter Linear? If F is a linear filter then it must satisfy: F(x + y) = F(x) + F(y) 1 1 1 0 0 0 1 1 1 1 1 2 + 0 1 0 = 1 2 2 2 2 2 0 0 0 2 2 2 Median Filter 1 + 0 = 2 Justin Johnson EECS 442 WI 2020: Lecture 8 - 34 February 4, 2020

  34. Sharpening Filter Image Smoothed - Details = Justin Johnson EECS 442 WI 2020: Lecture 8 - 35 February 4, 2020

  35. Sharpening Filter Image Details + α “Sharpened” α=1 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 36 February 4, 2020

  36. Sharpening Filter Image Details + α “Sharpened” α=0 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 37 February 4, 2020

  37. Sharpening Filter Image Details + α “Sharpened” α=2 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 38 February 4, 2020

  38. Sharpening Filter Image Details + α “Sharpened” α=0 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 39 February 4, 2020

  39. Sharpening Filter Image Details + α “Sharpened” α=10 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 40 February 4, 2020

  40. Filtering: Counting How many “on” pixels have 10+ neighbors within 10 pixels? Pixels Disk ??? ⁎ r=10 = Justin Johnson EECS 442 WI 2020: Lecture 8 - 41 February 4, 2020

  41. Filtering: Counting How many “on” pixels have 10+ neighbors within 10 pixels? Pixels Density Answer x = Justin Johnson EECS 442 WI 2020: Lecture 8 - 42 February 4, 2020

  42. Filtering: Missing Data Oh no! Missing data! (and we know where) Common with many non-normal cameras (e.g., depth cameras) Justin Johnson EECS 442 WI 2020: Lecture 8 - 43 February 4, 2020

  43. Filtering: Missing Data ⁎ Image Per-element Division Binary ⁎ Mask Justin Johnson EECS 442 WI 2020: Lecture 8 - 44 February 4, 2020

  44. Filtering: Missing Data Image Per-element Division Binary Mask Justin Johnson EECS 442 WI 2020: Lecture 8 - 45 February 4, 2020

Recommend


More recommend