125
CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

  • View
    220

  • Download
    2

Embed Size (px)

Citation preview

Page 1: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

CSCE 641 Computer Graphics:Image Filtering & Feature Detection

Jinxiang Chai

Page 2: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review

2D Fourier Transform

Nyquist sampling theory - Sampling Rate ≥ 2 * max frequency in the signal

Antialiasing - prefiltering

Gaussian pyramid - Mipmap

Page 3: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review

2D Fourier Transform

Nyquist sampling theory - Sampling Rate ≥ 2 * max frequency in the signal

Antialiasing - prefiltering

Gaussian pyramid - Mipmap

Page 4: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review: 2D Fourier Transform

Fourier Transform:

Inverse Fourier transform:

dvduevuFyxf vyuxi )(2),(),(

dydxeyxfvuF vyuxi )(2),(),(

Page 5: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review: Nyquist Sampling Rate

T 2T…-2T -T… 0

x

fs(x)

f(x)

x

Fs(u)

u-fmax fmax

F(u)

u-fmax fmax

)()( uboxuFs

Inverse Fourier transform

Fourier transform

Sampling Rate ≥ 2 * max frequency in the signal!

Page 6: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review: Antialiasing

Increase the sampling rate to above twice the highest frequency

Introduce an anti-aliasing filter to reduce fmax

u-fmax fmax

Fs(u)

u-fmax fmax

Page 7: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review: Antialiasing

Increase the sampling rate to above twice the highest frequency

Introduce an anti-aliasing filter to reduce fmax

u-fmax fmax

Fs(u)

u-fmax fmax

- Sinc filter

- Mean filter

- Triangular filter

- Gaussian filter

Page 8: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Known as a Gaussian Pyramid– MipMap (Williams, 1983)

Review: Image Pyramids

Page 9: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Outline

Image Processing

- Median filtering

- Bilateral filtering

- Edge detection

- Corner detection

Page 10: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Filtering

input Gaussian filter

Page 11: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter

• For each neighbor in image, sliding the window

• Sort pixel values• Set the center pixel to the median

Page 12: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter

input Gaussian filter Median filter

Page 13: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter Examples

input Median 7X7

Page 14: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter Examples

Median 11X11Median 3X3

Page 15: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter Examples

Median 11X11Median 3X3

Straight edges kept

Sharp features lost

Page 16: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Median Filter Properties

Can remove outliers (peppers and salts)

Window size controls size of structure

Preserve some details but sharp corners and edges might get lost

Page 17: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Mean with 6 pixels

Page 18: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Gaussian with 6 pixels

Page 19: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Comparison of Mean, Gaussian, and Median

original Median with 6 pixels

Page 20: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Page 21: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Page 22: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Page 23: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Can we find a filter that not only smooths regions but preserves sharp features such as edges?

Page 24: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Common Problems

Mean: blurs image, removes simple noise, no details are preserved

Gaussian: blurs image, preserves details only for small σ.

Median: preserves some details, good at removing strong noise

Can we find a filter that not only smooths regions but preserves sharp features such as edges?

- yes, bilateral filter

Page 25: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Outline

Image Processing

- Median filtering

- Bilateral filtering

- Edge detection

- Corner detection

Page 26: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

What Is Bilateral Filter?

Bilateral

- Affecting or undertaken by two sides equally

Property:

- Convolution filter

- Smooth image but preserve edges

- Operates in the domain and the range of image

Page 27: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Example

Gaussian filter Bilateral filter

Page 28: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Example

Gaussian filter Bilateral filter

Page 29: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

1D Graphical ExampleCenter Sample u

It is clear that in weighting this neighborhood, we would like to preserve the step

Neighborhood

I(p)

p

)(uneighborp

Page 30: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Weights

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Page 31: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Filtered Values

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 32: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edges Are Smoothed

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 33: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

What Causes the Problem?

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Page 34: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

What Causes the Problem?

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Filtered value

Same weights for these two pixels!!

Page 35: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Weights

)2

))()((exp()( 2

2

s

s

pIuIpW

)2

)(exp()( 2

2

c

c

pupW

p

I(p)

Page 36: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral filter

2

2 2

2

2 2

2 2

2 2

( )

'

c s

c s

I u I pu p

p N u

I u I pu p

p N u

e e I p

I u

e e

Denoise Feature preserving

Normalization

Bilateral FilteringBilateral Filtering

Page 37: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Kernel Properties

• Per each sample, we can define a ‘Kernel’ that averages its neighborhood

• This kernel changes from sample to sample!• The sum of the kernel entries is 1 due to the

normalization,• The center entry in the kernel is the largest,• Subject to the above, the kernel can take any

form (as opposed to filters which are monotonically decreasing).

p sc

p sc

pWpW

pIpWpWuI

)(*)(

)(*)(*)()(

Page 38: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Filter Parameters

As proposed by Tomasi and Manduchi, the filter is controlled by 3 parameters:

The filter can be applied for several iterations in order to further strengthen its edge-preserving smoothing

N(u) – The neighbor size of the filter support,c – The variance of the spatial distances,s – The variance of the value distances,

)(

)(

)(*)(

)(*)(*)()(

uNp sc

uNp sc

pWpW

pIpWpWuI

Page 39: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Page 40: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Page 41: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Wc

Page 42: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Wc Ws

Page 43: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Wc Ws Ws*Wc

Page 44: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter

input

Wc Ws Ws*Wc

Output

Page 45: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

Original

Page 46: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

σc = 3, σs = 3

Page 47: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

σc = 6, σs = 3

Page 48: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

σc = 12, σs = 3

Page 49: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

σc = 12, σs = 6

Page 50: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Bilateral Filter Results

σc = 15, σs = 8

Page 51: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Additional Comments

The bilateral filter is a powerful filter: - Can work with any reasonable distance function

Ws and Wc,

- Easily extended to higher dimension signals, e.g. Images, video, mesh, animation data etc.

- Easily extended to vectored-signals, e.g. RGB images or RGBD images etc.

[Fleishman et al, siggraph 03]Bilateral Mesh Denoising

Page 52: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Readings on Image Filtering

• Section 3.3.1 in Szeliski book

• Tomasi's Bilateral Filter

• more about bilateral filter, click here

Page 53: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Outline

Image Processing

- Median filtering

- Bilateral filtering

- Edge detection

- Corner detection

Page 54: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

What are edges in this image?

Page 55: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

What are edges in this image?

Page 56: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

One of the most important image processing problems

- really easy for human - really difficult for computers - fundamental for computer vision - very important for many graphics applications

How to tell a pixel is on the edge?

Page 57: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

One of the most important image processing problems

- really easy for human - really difficult for computers - fundamental for computer vision - very important for many graphics applications

How to tell a pixel is on the edge?

Page 58: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

One of the most important image processing problems

- really easy for human - really difficult for computers - fundamental for computer vision - very important for many graphics applications

How to tell a pixel is on the edge?

Page 59: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Edge Detection

One of the most important image processing problems

- really easy for human - really difficult for computers - fundamental for computer vision - very important for many graphics applications

How to tell a pixel is on the edge?- Related to the first-derivative.

- How to compute the first-derivatives of an image?

Page 60: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Gradient

A vector variable - Direction of the maximum growth of the function

- Magnitude of the growth

- Perpendicular to the edge direction

2

)/

/tan(

),(

),(

22

xf

yfa

y

f

x

fyxf

yy

fx

x

fyxf

),( yxf

Page 61: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Gradients

Page 62: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

How to Calculate Gradient?

How to compute ?x

f

Intensity

Pixel column

Page 63: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Good ole’ Taylor Series

Subtracting the second from the first we obtain

...)(''2

1)(')()( 2 xfhxhfxfhxf

...)(''2

1)(')()( 2 xfhxhfxfhxf

or…

)(2

)()()(' 2hO

h

hxfhxfxf

Page 64: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Discrete Gradient Estimation

For discrete functions, we can use the first order approximation of the gradient

where h corresponds to the step size

h

hxfhxfxf

2

)()()('

Page 65: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Discrete Gradient Estimation

For discrete functions, we can use the first order approximation of the gradient

where h corresponds to the step size

For our purposes, h corresponds to the width of 1 pixel =>

h

hxfhxfxf

2

)()()('

2

)1,()1,(),(2

),1(),1(),(

yxIyxI

y

yxI

yxIyxI

x

yxI

Page 66: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Discrete Gradient Estimation

So how can we compute the image gradient efficiently?

- Using our good old friend convolution!

1

0

1

*

101*

Iy

I

Ix

I

- Dropped off the “divide by 2” for speed considerations.- This only scales the gradient.

Page 67: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Taking the Discrete Derivative

] 1 0 1[

abs()

Page 68: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection Step 1

INPUT IMAGE

1) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

But isn’t edge detection susceptible to noise?

Page 69: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection Steps 1-2

INPUT IMAGE

2) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

1) NoiseSmoothing

16/

121

242

121

Page 70: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Discrete Gradient EstimationRemember that the gradient is a vector and we have calculated the coefficients in the x and y directions at each point in the image

After convolving, we get the magnitude of the gradient from at each point (pixel) from

In practice, we often sum the absolute values of the components for computational efficiency

22

),(

y

I

x

IyxG

Page 71: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection (cont’d)

INPUT IMAGE

1) NoiseSmoothing

2) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

2

122 ),(),(

|),(|

y

yxI

x

yxIyxI

“GRADIENT” IMAGE

16/

121

242

121

Page 72: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection (cont’d)

INPUT IMAGE

1) NoiseSmoothing

2) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

2

122 ),(),(

|),(|

y

yxI

x

yxIyxI

“GRADIENT” IMAGE

16/

121

242

121

What does the gradient image mean?

Page 73: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection (cont’d)

INPUT IMAGE

1) NoiseSmoothing

2) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

2

122 ),(),(

|),(|

y

yxI

x

yxIyxI

“GRADIENT” IMAGE

16/

121

242

121

What does the gradient image mean?

- Magnitude of intensity changes around each pixel

Page 74: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Discrete Gradient EstimationSo how do we segment the edges from the rest of the scene?

- Thresholding!

Page 75: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Effects of ThresholdingWhile edge features are independent of illumination, the edge strength is not!

Results from threshold values of 50 and 100

Page 76: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Edge Detection Summary

INPUT IMAGE

1) NoiseSmoothing

EDGE IMAGE

2) EdgeEnhancement

Horizontal [-1 0 1]

Vertical [-1 0 1]T

),( yxI

x

yxI

),(

y

yxI

),(

2

122 ),(),(

|),(|

y

yxI

x

yxIyxI

“GRADIENT” IMAGE

3)Threshold

16/

121

242

121

Page 77: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The effects of Filtering Noise

Threshold20

Gaussian SmoothingUnsmoothed Edges

Threshold50

Page 78: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Sobel Edge DetectionOne of the dominant edge detection schemes uses the Sobel

operators

Convolving each of these with the original image generates horizontal and vertical gradient images that are combined as before

101

202

101

VSobel

121

000

121

HSobel

Page 79: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Sobel Edge Detection

One of the dominant edge detection schemes uses the Sobel operators

101

202

101

VSobel

121

000

121

HSobel

- Can be approximated as a derivative of Gaussian

- First Gaussian smoothing and then compute derivatives

Ix

G

x

IG

)(

Page 80: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Sobel Edge Detection

One of the dominant edge detection schemes uses the Sobel operators

101

202

101

VSobel

121

000

121

HSobel

- Can be approximated as a derivative of Gaussian

- First Gaussian smoothing and then compute derivatives

Ix

G

x

IG

)( Why?

Page 81: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Sobel Edge Detection

One of the dominant edge detection schemes uses the Sobel operators

101

202

101

VSobel

121

000

121

HSobel

- Can be approximated as a derivative of Gaussian

- First Gaussian smoothing and then compute derivatives

- In practice we may still need to smooth for noise

Ix

G

x

IG

)(

Page 82: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Robert and Prewitt Edge Detectors

The Prewitt is similar to the Sobel, but uses a different kernel

Roberts was an early edge detector kernel

101

101

101

VP

111

000

111

HP

11

111R

11

112R

Page 84: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Second Derivative Edge Detector

Sobel Operator can produce thick edges; ideally we are looking for infinitely thin boundaries

Page 85: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Second Derivative Edge Detector

Sobel Operator can produce thick edges; ideally we are looking for infinitely thin boundaries

An alternative approach is to look for local extrema in the first derivative

A peak in the first derivative corresponds what in the second derivative?

Page 86: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Second Derivative Edge Detector

Sobel Operator can produce thick edges; ideally we are looking for infinitely thin boundaries

An alternative approach is to look for local extrema in the first derivative

A peak in the first derivative corresponds what in the second derivative?

Page 87: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Localization with Laplacian

An equivalent measure of the second derivative in 2D is the Laplacian:

Numerically, we approximate the Laplacian using the following filtering kernel:

Zeros crossing of the filter corresponds to positions of maximum gradient.

- can be used for detecting edges - might be sensitive to noise - need to filter the image

Page 88: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Laplacian of Gaussian Kernel

),()()),(( 22 yxIGyxIG

Page 89: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Review: Properties

Linearity:

Time shift:

Derivative:

Integration:

Convolution:

)()()()( ubGuaFxbgxaf

)()( 020 uFexxf uxi

)()(

uuFx

xdf

u

uFdxxf

)()(

)()()()( uGuFxgxf

)()()()( uGuFxgxf

Page 90: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Laplacian of Gaussian Kernel

),()()),(( 22 yxIGyxIG

2

22

24

222222 2

yx

eyx

x

G

x

GG

Page 91: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Laplacian of Gaussian Filter Kernel

0.1

4.1

Page 92: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Laplacian Edge Detector

Java applet: Click here

Page 93: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Readings

• Section 4.2 in Szeliski book

Page 94: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Outline

Image Processing

- Median filtering

- Bilateral filtering

- Edge detection

- Corner detection

Page 95: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection

Why do we need to detect corners?

- Corners correspond to points in both the world and image spaces

- Very important for image based rendering and modeling

- Very useful in computer vision

Page 96: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

What are Corners?

Point features

Page 97: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

What are Corners?

Point features

Where two edges come together

Where the image gradient has significant components in the x and y direction

We will establish corners from the gradient rather than the edge images

Page 98: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Ideas

What are gradients along x and y directions?

Page 99: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Ideas

What are gradients along x and y directions?

Page 100: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Ideas

What are gradients along x and y directions?

How to measure corners based on the gradient images?

Page 101: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Ideas

What are gradients along x and y directions?

How to measure corners based on the gradient images?How to measure corners based on the gradient images?

- two major axes in the local window!

Page 102: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Idea

• Corners: two major axes of gradients in the local window

• How to evaluate this?

Page 103: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Idea

• Corners: two major axes of gradients in the local window

• How to evaluate this?

y

x

I

IGradient vector

Page 104: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Idea

Ix

Iy

Page 105: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Basic Idea

Ix

Iy

Ix

Iy

Ix

Iy

Page 106: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Finding Two Major Axes

• Compute covariance matrix

• Compute two eigen values: λ1 and λ2, which indicate magnitude of two dominant axes

• If both λ1 and λ2 are large, then we have two dominant axes (corners).

Page 107: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

1. Compute the image gradients

2. Define a neighborhood size as an area of interest around each pixel

Corner Detection Algorithm

6160531918

5855531513

5555501313

1010101111

1012121110

y

yxII

x

yxII yx

),(,

),(

3x3 neighborhood

Page 108: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

3. For each image pixel (i,j), construct the following matrix from it and its neighborhood values

e.g.

Corner Detection Algorithm (cont’d)

6160531918

5855531513

5555501313

1010101111

1012121110

xI

2

2

),(yyx

yxx

T

y

x

y

xji III

III

I

I

I

IC

22222

2222)3,3(

5553155550

13101011]1,1[

C

Similar to covariance matrix (Ix,Iy)T!

Page 109: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection Algorithm (cont’d)

4. For each matrix C(i,j), determine the 2 eigenvalues λ(i.j)= [λ1, λ2].

- Eigenvalues indicate magnitude of two dominant axes

- If either λ1 or λ2 is close to zero, then this is not a corner.

Simple case:

Page 110: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection Algorithm (cont’d)

4. For each matrix C(i,j), determine the 2 eigenvalues λ(i.j)= [λ1, λ2].

Simple case:

Isolated pixelsInterior Region Edge Corner

λ1, λ2=0 Large λ1 and small λ2 Large λ1 and large λ2 small λ1 and small λ2

Page 111: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection Algorithm (cont’d)

4. For each matrix C(i,j), determine the 2 eigenvalues λ(i.j)= [λ1, λ2].

- This is just a rotated version of the one on last slide

- If either λ1 or λ2 is close to zero, then this is not a corner.

General case:

Page 112: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Eigen-values and Corner

- λ1 is large

- λ2 is large

Page 113: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Eigen-values and Corner

- λ1 is large

- λ2 is small

Page 114: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Eigen-values and Corner

- λ1 is small

- λ2 is small

Page 115: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection Algorithm (cont’d)

4. For each matrix C(i,j), determine the 2 eigenvalues λ(i.j)= [λ1, λ2].

5. If both λ1 and λ2 are big, we have a corner (Harris also checks the ratio of λs is not too high)

ISSUE: The corners obtained will be a function of the threshold !

Page 116: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Image Gradients

Page 117: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Image Gradients

Closeup of image orientation at each pixel

Page 118: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Orientation Field

Corners are detected where both λ1 and λ2 are big

Page 119: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

The Orientation Field

Corners are detected where both λ1 and λ2 are big

Page 120: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Corner Detection Sample Results

Threshold=25,000 Threshold=10,000

Threshold=5,000

Page 121: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Results

Page 122: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Required Readings

• Section 4.1.1 in Szeliski book   

• Harris corner detector

Page 123: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Homework #1

• Due by 9/23, midnight

• Submit it via csnet.

• If you do not have the csnet account, submit it to me via email.

Page 124: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Summary

Image Processing - Median filtering

- Bilateral filtering

- Edge detection

- Corner detection

Page 125: CSCE 641 Computer Graphics: Image Filtering & Feature Detection Jinxiang Chai

Next Lecture

SIFT features

Image composition and blending

Image warping

Image morphing