+ All Categories
Home > Documents > Gradient

Gradient

Date post: 15-Feb-2016
Category:
Upload: deepak
View: 31 times
Download: 0 times
Share this document with a friend
Description:
Gradient. In the one-dimensional case, a step edge corresponds to a local peak in the first derivative of the intensity function. In the two-dimensional case, we analyze the gradient instead of the first derivative. - PowerPoint PPT Presentation
Popular Tags:
22
September 26, 2013 Computer Vision Lecture 8: Edge Detection II 1 Gradient In the one-dimensional case, a step edge corresponds to a local peak in the first derivative of the intensity function. In the two-dimensional case, we analyze the gradient instead of the first derivative. Just like the first derivative, the gradient measures the change in a function. For two-dimensional functions it is defined as y f x f j i G G y x f G )] , ( [
Transcript
Page 1: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

1

GradientIn the one-dimensional case, a step edge corresponds to a local peak in the first derivative of the intensity function.In the two-dimensional case, we analyze the gradient instead of the first derivative.Just like the first derivative, the gradient measures the change in a function.For two-dimensional functions it is defined as

yf

xf

j

iGG

yxfG )],([

Page 2: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

2

GradientGradients of two-dimensional functions:

The two-dimensional function in the left diagram is represented by contour lines in the right diagram, where arrows indicate the gradient of the function at different locations. Obviously, the gradient is always pointing in the direction of the steepest increase of the function.

Page 3: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

3

GradientIn order to compute Gx and Gy in an image F at position [i, j], we need to consider the discrete case and get:Gi = F[i+1, j] – F[i, j] Gj = F[i, j+1] – F[i, j] This can be done with convolution filters:

Gj = -1 1 1

-1Gi =

To be precise in the assignment of gradients to pixels and to reduce noise, we usually apply 33 filters instead (next slide).

Page 4: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

4

Sobel Filters

• Sobel filters are the most common variant of edge detection filters.

• Two small convolution filters are used successively:

Sj

-101

-202

-101

-1-2-1

000

121

Si

Page 5: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

5

Sobel FiltersSobel filters yield two interesting pieces of information:• The magnitude of the gradient (local change in brightness):

22|| ji ssG

• The angle of the gradient (tells us about the orientation of an edge):

j

i

ssarctan

Page 6: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

6

Sobel Filters

Calculating the magnitude of the brightness gradient with a Sobel filter. Left: original image; right: filtered image.

Page 7: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

7

Laplacian Filters• Let us take a look at the

one-dimensional case:• A change in brightness:

• Its first derivative:

• Its second derivative:

Page 8: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

8

Laplacian FiltersIdea:• Smooth the image,• compute the second derivative of the (2D) image,• Find the pixels where the brightness function “crosses” 0 and mark them.

We can actually devise convolution filters that carry out the smoothing and the computation of the second derivative.

Page 9: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

9

Laplacian Filters

2

2

2

22

yf

xff

xjiji

xG

xf x

]),[]1,[(

2

2 FF

xji

xji

],[]1,[( FF

]),[]1,[(])1,[]2,[( jijijiji FFFF

],[]1,[2]2,[ jijiji FFF

Page 10: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

10

Laplacian Filters

]1,[],[2]1,[2

2

jijijixf FFF

Since we want the computation centered at [i,j]:

],1[],[2],1[2

2

jijijiyf

FFF

Obviously, each function can be computed using a 1, -2, 1 convolution filter in horizontal or vertical direction.Since 2 is defined as the sum of these two functions, we can use a single 33 (or larger) convolution filter for its computation (next slide).

Page 11: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

11

Laplacian Filters

Continuous variant:

Discrete variants(applied after smoothing):

0 1 0

1 -4 1

0 1 0

1 1 1

1 -8 1

1 1 1

Page 12: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

12

Laplacian Filters

Let us apply a Laplacian filter to the same image:

Page 13: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

13

Laplacian Filters

33 Laplacian

55 Laplacian

zero detection zero detection zero detection

77 Laplacian

Page 14: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

14

Gaussian Edge DetectionAs you know, one of the problems in edge detection is the noise in the input image.Noise creates lots of local intensity gradients that can trigger unwanted responses by edge detection filters.We can reduce noise through (Gaussian) smoothing, but there is a trade-off:Stronger smoothing will remove more of the noise, but will also add uncertainty to the location of edges.For example, if two parallel edges are close to each other and we use a strong (i.e., large) Gaussian filter, these edges may be merged into one.

Page 15: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

15

Canny Edge DetectorThe Canny edge detector is a good approximation of the optimal operator, i.e., the one that maximizes the product of signal-to-noise ratio and localization.Basically, the Canny edge detector is the first derivative of a Gaussian function.Let I[i, j] be our input image.We apply our usual Gaussian filter with standard deviation to this image to create a smoothed image S[i, j]:S[i, j] = G[i, j; ] * I[i, j]

Page 16: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

16

Canny Edge DetectorIn the next step, we take the smoothed array S[i, j] and compute its gradient.We apply 22 filters to approximate the vertical derivative P[i, j] and the horizontal derivative Q[i, j]:P[i, j] (S[i+1, j] – S[i, j] + S[i+1, j+1] – S[i, j+1])/2Q[i, j] (S[i, j+1] – S[i, j] + S[i+1, j+1] – S[i+1, j])/2As you see, we average over the 22 square so that the point for which we compute the gradient is the same for the horizontal and vertical components(the center of the 22 square).

Page 17: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

17

Canny Edge DetectorP and Q can be computed using 22 convolution filters:

-0.5-0.5

0.5 0.5P:

-0.5 0.5

-0.5 0.5Q:

We use the upper left element as the reference point of the filter.That means when we place the filter on the image, the location of the upper left element indicates where to enter the resulting value into the new image.

Page 18: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

18

Canny Edge DetectorOnce we have computed P[i, j] and Q[i, j], we can also compute the magnitude and orientation of the gradient vector at position [i, j]:

22 ],[],[],[ jiQjiPjiM

]),[],,[arctan(],[ jiPjiQji

This is exactly the information that we want – it tells us where edges are, how significant they are, and what their orientation is.However, this information is still very noisy.

Page 19: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

19

Canny Edge DetectorThe first problem is that edges in images are not usually indicated by perfect step edges in the brightness function.Brightness transitions usually have a certain slope that extends across many pixels.As a consequence, edges typically lead to wide lines of high gradient magnitude.However, we would like to find thin lines that most precisely describe the boundary between two objects.This can be achieved with the nonmaxima suppression technique.

Page 20: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

20

Canny Edge DetectorWe first assign a sector [i, j] to each pixel according to its associated gradient orientation [i, j].There are four sectors with numbers 0, …, 3:

270 90

225

180

135

45

0

315

2

2

2

2

3

3

3

3

0 0

0 0

11

1

1

Page 21: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

21

Canny Edge DetectorThen we iterate through the array M[i, j] and compare each element to two of its 8-neighbors.Which two neighbors we choose depends on the value of [i, j].In the following diagram, the numbers in the neighboring squares of [i, j] indicate the value of [i, j] for which these neighbors are chosen:

1 0 32 [i,j] 2

3 0 1

Page 22: Gradient

September 26, 2013 Computer Vision Lecture 8: Edge Detection II

22

Canny Edge DetectorIf the value of M[i, j] is less than either of the M-values in these two neighboring positions, set E[i, j] = 0.Otherwise, set E[i, j] = M[i, j].The resulting array E[i, j] is of the same size as M[i, j] and contains values greater than zero only at local maxima of gradient magnitude (measured in local gradient direction).Notice that an edge in an image always induces an intensity gradient that is perpendicular to the orientation of the edge.Thus, this nonmaxima suppression technique thins the detected edges to a width of one pixel.


Recommended