39
Zoom Lenses – Varifocal Zoom Lenses – Varifocal

Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f x o / d o = x i / d

  • View
    221

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Zoom Lenses – VarifocalZoom Lenses – Varifocal

Page 2: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Zoom Lenses – ParfocalZoom Lenses – Parfocal

Page 3: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Computing Field of ViewComputing Field of View

xxoo

ddii

xxii

ddoo

1/1/ddoo + 1/ + 1/ddii = 1/ = 1/ff

xxo o / / ddoo = = xxi i / / ddii

= 2 tan= 2 tan-1-1 ½ ½ xxi i

(1/(1/ff1/1/ddoo))Since typically Since typically ddoo >> >> f,f,

2 tan2 tan-1-1 ½ ½ xxi i / / ff

tan tan /2 = ½ /2 = ½ xxo o // ddoo

xxi i / / ff

Page 4: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Filtering and Edge Filtering and Edge DetectionDetection

Page 5: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Local NeighborhoodsLocal Neighborhoods

• Hard to tell anything from a single Hard to tell anything from a single pixelpixel– Example: you see a reddish pixel. Is Example: you see a reddish pixel. Is

this the object’s color? Illumination? this the object’s color? Illumination? Noise?Noise?

• The next step in order of complexity The next step in order of complexity is to look at local neighborhood of a is to look at local neighborhood of a pixelpixel

Page 6: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Linear FiltersLinear Filters

• Given an image Given an image InIn((xx,,yy) generate a) generate anew image new image OutOut((xx,,yy):):– For each pixel (For each pixel (xx,,yy))

OutOut((xx,,yy) is a linear combination of ) is a linear combination of pixelspixelsin the neighborhood of in the neighborhood of InIn((xx,,yy))

• This algorithm isThis algorithm is– Linear in input intensityLinear in input intensity– Shift invariantShift invariant

Page 7: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Discrete ConvolutionDiscrete Convolution

• This is the discrete analogue of This is the discrete analogue of convolutionconvolution

• The pattern of weights is called the The pattern of weights is called the “kernel” of the filter“kernel” of the filter

• Will be useful in smoothing, edge Will be useful in smoothing, edge detectiondetection

Page 8: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Example: SmoothingExample: Smoothing

Original: MandrillOriginal: Mandrill Smoothed withSmoothed withGaussian kernelGaussian kernel

Page 9: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Gaussian FiltersGaussian Filters

• One-dimensional GaussianOne-dimensional Gaussian

• Two-dimensional GaussianTwo-dimensional Gaussian

2

2

21

2

1)(

x

exG

2

2

21

2

1)(

x

exG

2

22

22

2

1),(

yx

eyxG

2

22

22

2

1),(

yx

eyxG

Page 10: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Gaussian FiltersGaussian Filters

Page 11: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Gaussian FiltersGaussian Filters

Page 12: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Gaussian FiltersGaussian Filters

• Gaussians are used because:Gaussians are used because:– SmoothSmooth– Decay to zero rapidlyDecay to zero rapidly– Simple analytic formulaSimple analytic formula– Limit of applying multiple filters is Limit of applying multiple filters is

GaussianGaussian– Separable:Separable:

G G22(x,y) = G(x,y) = G11(x) G(x) G11(y)(y)

Page 13: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Computing ConvolutionsComputing Convolutions

• What happens near edges of image?What happens near edges of image?– Ignore (Ignore (OutOut is smaller than is smaller than InIn))– Pad with zeros (edges get dark)Pad with zeros (edges get dark)– Replicate edge pixelsReplicate edge pixels– Wrap aroundWrap around– ReflectReflect– Change filterChange filter– ……

i j

jyixInjifyxOut ),(),(),( i j

jyixInjifyxOut ),(),(),(

Page 14: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Computing ConvolutionsComputing Convolutions

• If If InIn is is nnnn, , ff is is mmmm, takes time, takes time O( O(mm22nn22))

• OK for small filter kernels, bad for OK for small filter kernels, bad for large oneslarge ones

i j

jyixInjifyxOut ),(),(),( i j

jyixInjifyxOut ),(),(),(

Page 15: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Digression: Fourier Digression: Fourier TransformsTransforms

• Define Define Fourier transformFourier transform of function of function ff asas

• F is a function of frequency – F is a function of frequency – describes how much of each describes how much of each frequency frequency ff contains contains

• Fourier transform is invertibleFourier transform is invertible

dxexf xixf

)(

2

1)(F )(F dxexf xixf

)(

2

1)(F )(F

Page 16: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Fourier Transform and Fourier Transform and ConvolutionConvolution

• Fourier transform turns convolutionFourier transform turns convolutioninto multiplication:into multiplication:

FF ((ff((xx) ) gg((xx)))) = = FF ((ff((xx)))) FF

((gg((xx))))

Page 17: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Fourier Transform and Fourier Transform and ConvolutionConvolution

• Useful application #1: Use frequency Useful application #1: Use frequency space to understand effects of filtersspace to understand effects of filters– Example: Fourier transform of a Example: Fourier transform of a

GaussianGaussianis a Gaussianis a Gaussian

– Thus: attenuates high frequenciesThus: attenuates high frequencies

==

Page 18: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Fourier Transform and Fourier Transform and ConvolutionConvolution

• Useful application #2: Efficient Useful application #2: Efficient computationcomputation– Fast Fourier Transform (FFT) takes timeFast Fourier Transform (FFT) takes time

O( O(n n log log nn))– Thus, convolution can be performed in Thus, convolution can be performed in

timetime O( O(nn log log nn + + mm log log mm))

– Greatest efficiency gains for large Greatest efficiency gains for large filtersfilters

Page 19: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Edge DetectionEdge Detection

• What do we mean by edge What do we mean by edge detection?detection?

• What is an edge?What is an edge?

Page 20: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

What is an Edge?What is an Edge?

Edge easy to findEdge easy to find

Page 21: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

What is an Edge?What is an Edge?

Where is edge? Single pixel wide or multiple pixels?Where is edge? Single pixel wide or multiple pixels?

Page 22: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

What is an Edge?What is an Edge?

Noise: have to distinguish noise from actual edgeNoise: have to distinguish noise from actual edge

Page 23: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

What is an Edge?What is an Edge?

Is this one edge or two?Is this one edge or two?

Page 24: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

What is an Edge?What is an Edge?

Texture discontinuityTexture discontinuity

Page 25: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Formalizing Edge DetectionFormalizing Edge Detection

• Look for strong step edgesLook for strong step edges

• One pixel wide: look for One pixel wide: look for maximamaxima in in dI dI / / dxdx

• Noise rejection: smooth (with a Noise rejection: smooth (with a Gaussian) over a neighborhood Gaussian) over a neighborhood

dx

dI dx

dI

Page 26: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• SmoothSmooth

• Find derivativeFind derivative

• Find maximaFind maxima

• ThresholdThreshold

Page 27: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• First, smooth with a Gaussian ofFirst, smooth with a Gaussian ofsome width some width

Page 28: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• Next, find “derivative”Next, find “derivative”

• What is derivative in 2D? Gradient:What is derivative in 2D? Gradient:

y

f

x

fyxf ,),(

y

f

x

fyxf ,),(

Page 29: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• Useful fact #1: differentiation Useful fact #1: differentiation “commutes” with convolution“commutes” with convolution

• Useful fact #2: Gaussian is separableUseful fact #2: Gaussian is separable

gdx

dfgf

dx

d g

dx

dfgf

dx

d

Page 30: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• Thus, combine first two stages of Thus, combine first two stages of Canny:Canny:

),(

)(),,(

)(),( 11

2 yxfdy

ydGyxf

dx

xdGyxfG

),(

)(),,(

)(),( 11

2 yxfdy

ydGyxf

dx

xdGyxfG

Page 31: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

Original: LenaOriginal: Lena Smoothed Gradient MagnitudeSmoothed Gradient Magnitude

Page 32: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• Nonmaximum suppressionNonmaximum suppression– Eliminate all but local maxima in Eliminate all but local maxima in

magnitudemagnitudeof gradientof gradient

– At each pixel look along At each pixel look along direction direction of of gradient:gradient:if either neighbor is bigger, set to zeroif either neighbor is bigger, set to zero

– In practice, quantize direction to In practice, quantize direction to horizontal, vertical, and two diagonalshorizontal, vertical, and two diagonals

– Result: “thinned edge image”Result: “thinned edge image”

Page 33: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

• Final stage: thresholdingFinal stage: thresholding

• Simplest: use a single thresholdSimplest: use a single threshold

• Better: use two thresholdsBetter: use two thresholds– Find chains of edge pixels, all greater than Find chains of edge pixels, all greater than

low low

– Each chain must contain at least one pixel Each chain must contain at least one pixel greater than greater than high high

– Helps eliminate dropouts in chains, Helps eliminate dropouts in chains, without being too susceptible to noisewithout being too susceptible to noise

– ““Thresholding with hysteresis”Thresholding with hysteresis”

Page 34: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Canny Edge DetectorCanny Edge Detector

Original: LenaOriginal: Lena EdgesEdges

Page 35: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Other Edge DetectorsOther Edge Detectors

• Can build simpler, faster edge Can build simpler, faster edge detector by omitting some steps:detector by omitting some steps:– No nonmaximum suppressionNo nonmaximum suppression– No hysteresis in thresholdingNo hysteresis in thresholding– Simpler filterSimpler filter

Page 36: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Second-Derivative-BasedSecond-Derivative-BasedEdge DetectorsEdge Detectors

• To find local maxima in derivative, To find local maxima in derivative, look for zeros in second derivativelook for zeros in second derivative

• Analogue in 2D: LaplacianAnalogue in 2D: Laplacian

2

2

2

22 ),(

y

f

x

fyxf

2

2

2

22 ),(

y

f

x

fyxf

Page 37: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

LOGLOG

• As before, combine Laplacian with As before, combine Laplacian with Gaussian smoothing: Laplacian of Gaussian smoothing: Laplacian of Gaussian (LOG)Gaussian (LOG)

Page 38: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

LOGLOG

• As before, combine Laplacian with As before, combine Laplacian with Gaussian smoothing: Laplacian of Gaussian smoothing: Laplacian of Gaussian (LOG)Gaussian (LOG)

Page 39: Zoom Lenses – Varifocal. Zoom Lenses – Parfocal Computing Field of View xoxoxoxo didididi xixixixi dodododo 1/d o + 1/d i = 1/f  x o / d o = x i / d

Problems withProblems withLaplacian Edge DetectorsLaplacian Edge Detectors

• Local minimum vs. local maximumLocal minimum vs. local maximum

• Symmetric – poor performance near Symmetric – poor performance near cornerscorners

• Sensitive to noise along an edgeSensitive to noise along an edge– Higher-order derivatives = greater noise Higher-order derivatives = greater noise

sensitivitysensitivity