CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu Lecture 7 – Linear Filters 1.

Slides:



Advertisements
Similar presentations
Linear Filtering – Part I Selim Aksoy Department of Computer Engineering Bilkent University
Advertisements

Motion illusion, rotating snakes. Slide credit Fei Fei Li.
Computational Photography CSE 590 Tamara Berg Filtering & Pyramids.
Computational Photography Prof. Feng Liu Spring /06/2015.
Spatial Filtering Dan Witzner Hansen. Recap Exercises??? Feedback Last lectures?
Lecture 4 Linear Filters and Convolution
1 Image filtering Hybrid Images, Oliva et al.,
Lecture 1: Images and image filtering
1 Image Filtering Readings: Ch 5: 5.4, 5.5, 5.6,5.7.3, 5.8 (This lecture does not follow the book.) Images by Pawan SinhaPawan Sinha formal terminology.
Linear filtering. Overview: Linear filtering Linear filters Definition and properties Examples Gaussian smoothing Separability Applications Denoising.
1 Linear image transforms Let’s start with a 1-D image (a “signal”): A very general and useful class of transforms are the linear transforms of f, defined.
Announcements Kevin Matzen office hours – Tuesday 4-5pm, Thursday 2-3pm, Upson 317 TA: Yin Lou Course lab: Upson 317 – Card access will be setup soon Course.
15-463: Computational Photography Alexei Efros, CMU, Fall 2011 Many slides from Steve Marschner Sampling and Reconstruction.
1 Image filtering Images by Pawan SinhaPawan Sinha.
1 Image filtering
Lecture 2: Image filtering
1 Images and Transformations Images by Pawan SinhaPawan Sinha.
Linear filtering.
1 Image filtering Hybrid Images, Oliva et al.,
Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Most slides from Steve Seitz
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean Hall 5409 T-R 10:30am – 11:50am.
Lecture 1: Images and image filtering CS4670/5670: Intro to Computer Vision Kavita Bala Hybrid Images, Oliva et al.,
Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003  Lecture 9.
Computer Vision – Lecture 3
Applications of Image Filters Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/04/10.
Machine Vision ENT 273 Image Filters Hema C.R. Lecture 5.
Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
Linear Filters Monday, Jan 24 Prof. Kristen Grauman UT-Austin …
Linear Filters August 27 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Devi Parikh Disclaimer: Many slides have been borrowed from Kristen Grauman,
Image Filtering Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/02/10.
Why is computer vision difficult?
Linear filtering. Motivation: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What’s.
Machine Vision ENT 273 Image Filters Hema C.R. Lecture 5.
Visual Computing Computer Vision 2 INFO410 & INFO350 S2 2015
CS 691B Computational Photography
Pixels and Image Filtering Computational Photography Derek Hoiem 08/26/10 Graphic:
Reconnaissance d’objets et vision artificielle
Linear filtering. Motivation: Image denoising How can we reduce noise in a photograph?
CSE 185 Introduction to Computer Vision Image Filtering: Spatial Domain.
Grauman Today: Image Filters Smooth/Sharpen Images... Find edges... Find waldo…
Lecture 1: Images and image filtering CS4670/5670: Intro to Computer Vision Noah Snavely Hybrid Images, Oliva et al.,
Image Filtering in Spatial domain
Linear Filters T-11 Computer Vision University of Houston
Linear Filters April 6th, 2017
Pixels and Image Filtering
Filtering – Part I Gokberk Cinbis Department of Computer Engineering
Lecture 1: Images and image filtering
Image filtering Hybrid Images, Oliva et al.,
Recap from Wednesday Spectra and Color Light capture in cameras and humans.
Image gradients and edges April 11th, 2017
Image filtering Images by Pawan Sinha.
Sampling and Reconstruction
Image filtering Images by Pawan Sinha.
Image Processing Today’s readings For Monday
Image filtering Images by Pawan Sinha.
Motion illusion, rotating snakes
Linear filtering.
Most slides from Steve Seitz
Image filtering Images by Pawan Sinha.
Linear Filtering CS 678 Spring 2018.
Image filtering
Image filtering
Department of Computer Engineering
Lecture 2: Image filtering
Lecture 1: Images and image filtering
Image Filtering Readings: Ch 5: 5. 4, 5. 5, 5. 6, , 5
Most slides from Steve Seitz
Lecture: Pixels and Filters
Lecture: Pixels and Filters
Presentation transcript:

CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu Lecture 7 – Linear Filters 1

Schedule Last class – Color Today – Linear filters and convolution Readings for today: Szeliski 3.2; Forsyth and Ponce (optional). 2

Slide Credits Rob Fergus – NYU Darell Trevor – UC Berkeley Fei Fei Li - Stanford Svetlana Lazebnik – UIUC David A. Forsyth - UIUC 3

Image Filters Smooth/Sharpen Images... Find edges... Find waldo… 4

Overview Images as functions Linear filters Convolution and correlation 5

Overview Images as functions Linear filters Convolution and correlation 6

Images as functions We can think of an image as a function, f, from R 2 to R : f( x, y ) gives the intensity at position ( x, y ) Realistically, we expect the image only to be defined over a rectangle, with a finite range: –f: [a,b] x [c,d]  [0, 1.0] A color image is just three functions pasted together. We can write this as a “vector-valued” function: Source: S. Seitz 7

Images as functions An image contains discrete number of pixels, e.g. – “grayscale” (or “intensity”): [0,255] Source: F.F Lei 8

Images as functions An image contains discrete number of pixels, e.g. – “grayscale” (or “intensity”): [0,255] – Color RGB: [R, G, B] Lab: [L, a, b] HSV: [H, S, V] Source: F.F Lei 9

Images as discrete functions In computer vision we operate on digital (discrete) images: – Sample the 2D space on a regular grid – Quantize each sample (round to nearest integer) Image thus represented as a matrix of integer values. 1D 2D 10

Images as discrete functions Cartesian coordinates 11

Overview Images as functions Linear filters Convolution and correlation 12

Motivation Filtering: – Form a new image whose pixels are a combination original pixel values Goals: – Extract useful information from the images Features (edges, corners, blobs…) – Modify or enhance image properties: super-­resolution; in-painting; de­‐noising 13

Source: F.F. Li 14

Motivation: noise reduction We can measure noise in multiple images of the same static scene. How could we reduce the noise, i.e., give an estimate of the true intensities? What if there’s only one image? 15

Common types of noise – Salt and pepper noise: random occurrences of black and white pixels – Impulse noise: random occurrences of white pixels – Gaussian noise: variations in intensity drawn from a Gaussian normal distribution Source: S. Seitz 16

Gaussian noise Fig: M. Hebert >> noise = randn(size(im)).*sigma; >> output = im + noise; 17

Effect of sigma on Gaussian noise: Image shows the noise values themselves. 18

Effect of sigma on Gaussian noise: Image shows the noise values themselves. 19

Effect of sigma on Gaussian noise: Image shows the noise values themselves. 20

sigma=1 Effect of sigma on Gaussian noise: This shows the noise values added to the raw intensities of an image. 21

sigma=16 Effect of sigma on Gaussian noise This shows the noise values added to the raw intensities of an image. 22

First attempt at a solution Let’s replace each pixel with an average of all the values in its neighborhood Assumptions: – Expect pixels to be like their neighbors – Expect noise processes to be independent from pixel to pixel 23

First attempt at a solution Let’s replace each pixel with an average of all the values in its neighborhood Moving average in 1D: Source: S. Marschner 24

Weighted Moving Average Can add weights to our moving average Weights [1, 1, 1, 1, 1] / 5 Source: S. Marschner 25

Weighted Moving Average Non-uniform weights [1, 4, 6, 4, 1] / 16 Source: S. Marschner 26

Moving Average In 2D Source: S. Seitz 27

Moving Average In 2D Source: S. Seitz 28

Moving Average In 2D Source: S. Seitz 29

Moving Average In 2D Source: S. Seitz 30

Moving Average In 2D Source: S. Seitz 31

Moving Average In 2D Source: S. Seitz 32

Correlation filtering Say the averaging window size is 2k+1 x 2k+1: Loop over all pixels in neighborhood around image pixel F[i,j] Attribute uniform weight to each pixel Now generalize to allow different weights depending on neighboring pixel’s relative position: Non-uniform weights 33

Correlation filtering Filtering an image: replace each pixel with a linear combination of its neighbors. The filter “kernel” or “mask” H[u,v] is the prescription for the weights in the linear combination. This is called cross-correlation, denoted 34

Averaging filter What values belong in the kernel H for the moving average example? “box filter” ? 35

Smoothing by averaging depicts box filter original filtered 36

Gaussian filter What if we want nearest neighboring pixels to have the most influence on the output? This kernel is an approximation of a Gaussian function: Source: S. Seitz 37

Smoothing with a Gaussian 38

Gaussian filters What parameters matter here? Size of kernel or mask – Note, Gaussian function has infinite support, but discrete filters use finite kernels σ = 5 with 10 x 10 kernel σ = 5 with 30 x 30 kernel 39

Gaussian filters What parameters matter here? Variance of Gaussian: determines extent of smoothing σ = 2 with 30 x 30 kernel σ = 5 with 30 x 30 kernel 40

Matlab >> hsize = 10; >> sigma = 5; >> h = fspecial(‘gaussian’ hsize, sigma); >> mesh(h); >> imagesc(h); >> outim = imfilter(im, h); >> imshow(outim); outim 41

Boundary issues What is the size of the output? 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 f gg gg f gg g g f gg gg full samevalid Source: S. Lazebnik 42

Boundary issues What about near the edge? – the filter window falls off the edge of the image – need to extrapolate – methods: clip filter (black) wrap around copy edge reflect across edge Source: S. Marschner 43

Boundary issues What about near the edge? – the filter window falls off the edge of the image – need to extrapolate – methods (MATLAB): clip filter (black): imfilter(f, g, 0) wrap around:imfilter(f, g, ‘circular’) copy edge: imfilter(f, g, ‘replicate’) reflect across edge: imfilter(f, g, ‘symmetric’) Source: S. Marschner 44

Filtering an impulse signal abc def ghi What is the result of filtering the impulse signal (image) F with the arbitrary kernel H? ? 45

Filtering an impulse signal (correlation) abc def ghi What is the result of filtering the impulse signal (image) F with the arbitrary kernel H? ihg fed cba 46

Filtering an impulse signal (convolution) abc def ghi What is the result of filtering the impulse signal (image) F with the arbitrary kernel H? abc def ghi 47

Convolution Convolution: – Flip the filter in both dimensions (bottom to top, right to left) – Then apply cross-correlation Notation for convolution operator F H 48

Convolution vs. correlation Convolution Cross-correlation For a Gaussian or box filter, how will the outputs differ? If the input is an impulse signal, how will the outputs differ? 49

Convolution Convolution: – Flip the filter in both dimensions (bottom to top, right to left) – Then apply cross-correlation Notation for convolution operator F H 50

Smoothing with a Gaussian for sigma=1:3:10 h = fspecial('gaussian‘, fsize, sigma); out = imfilter(im, h); imshow(out); pause; end … Parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing. 51

Convolving with linear filters Original ? Source: D. Lowe 52

Convolving with linear filters Original Source: D. Lowe Filtered (no change) 53

Convolving with linear filters ? Source: D. Lowe Original 54

Convolving with linear filters Source: D. Lowe OriginalShifted left by 1 pixel with correlation 55

Practice with linear filters ? Source: D. Lowe Original 56

Practice with linear filters ? Source: D. Lowe OriginalBlur (with a box filter) 57

Practice with linear filters ? Source: D. Lowe Original 58

Practice with linear filters ? Source: D. Lowe Original Sharpening filter - Accentuates differences with local average 59

What does blurring remove? Now let’s add it back…… 60

Shift invariant linear system Shift invariant: – Operator behaves the same everywhere, i.e. the value of the output depends on the pattern in the image neighborhood, not the position of the neighborhood. Linear: – Superposition: h * (f1 + f2) = (h * f1) + (h * f2) – Scaling : h * (k f) = k (h * f) 61

Properties of convolution Linear & shift invariant Commutative: f * g = g * f Associative (f * g) * h = f * (g * h) Identity: unit impulse e = […, 0, 0, 1, 0, 0, …]. f * e = f Differentiation: 62

Separability In some cases, filter is separable, and we can factor into two steps: – Convolve all rows – Convolve all columns 63

Separability In some cases, filter is separable, and we can factor into two steps: e.g., What is the computational complexity advantage for a separable filter of size k x k, in terms of number of operations per output pixel? f * (g * h) = (f * g) * h g h f 64

Median filter No new pixel values introduced Removes spikes: good for impulse, salt & pepper noise 65

Median filter Salt and pepper noise Median filtered Source: M. Hebert Plots of a row of the image 66

Median filter Median filter is edge preserving 67

Filters for features Previously, thinking of filtering as a way to remove or reduce noise Now, consider how filters will allow us to abstract higher-level “features”. – Map raw pixels to an intermediate representation that will be used for subsequent processing – Goal: reduce amount of data, discard redundancy, preserve what’s useful 68

Template matching Filters as templates: Note that filters look like the effects they are intended to find --- “matched filters” Use normalized cross-correlation score to find a given pattern (template) in the image. – Szeliski Eq Normalization needed to control for relative brightnesses. 69

Template matching Scene Template (mask) A toy example 70

Template matching Template Detected template 71

Template matching Detected templateCorrelation map 72

Where’s Waldo? Scene Template 73

Where’s Waldo? Scene Template 74

Where’s Waldo? Detected templateCorrelation map 75

Template matching Scene Template What if the template is not identical to some subimage in the scene? 76

Template matching Detected template Template Match can be meaningful, if scale, orientation, and general appearance is right. 77

Filters and Convolution - Crucial Points A filter is a pattern of weights (<< ||image||) Convolution applies the filter to the image Output measures similarity between filter and image patch – only a rough estimate Normalized correlation gives improved pattern detection 78

Next class Pyramids and scale space Readings for next lecture: – Forsyth and Ponce 4.7; Szeliski 3.5 (optional) Readings for today: – Szeliski 3.2, Forsyth and Ponce (optional). 79

Questions 80