OpenStax-CNX

You are here: Home » Content » Edge Detection

Recently Viewed

This feature requires Javascript to be enabled.

Edge Detection

Edge Detection via 2D Convolution

Edges in an image are regions of sharp change, often at the boundaries between objects. One way to quantitatively find edges in an image is to analyze the pixel values of an image and examine the gradient of the pixel values matrix. Edges are identified as maxima in the gradient of an image. By using 2-Dimensional convolution and the pixel value matrix for each frame from a movie, the gradient can be calculated and used to find the edges.

2D Convolution

For our adaptive ROI system, the pixel value matrix was convolved with two different matrices (h1 and h2) using the following formula:

x = i = 0 k1 j = 0 k2 x ( i , j ) h ( m i , n j ) x = i = 0 k1 j = 0 k2 x ( i , j ) h ( m i , n j ) size 12{ nabla x= Sum cSub { size 8{i=0} } cSup { size 8{k1} } { Sum cSub { size 8{j=0} } cSup { size 8{k2} } {x $$i,j$$ h $$m - i,n - j$$ } } } {}
(1)

Where:

x = gradient x = gradient size 12{ nabla x= ital "gradient"} {}
(2)
x = image x = image size 12{x= ital "image"} {}
(3)

h1=101202101h1=101202101 size 12{h_1= left [ matrix { - 1 {} # 0 {} # 1 {} ## - 2 {} # 0 {} # 2 {} ## - 1 {} # 0 {} # 1{} } right ]} {} and h2=121000121h2=121000121 size 12{h_2= left [ matrix { 1 {} # 2 {} # 1 {} ## 0 {} # 0 {} # 0 {} ## - 1 {} # - 2 {} # - 1{} } right ]} {}

The result of convolution with h1 gives the horizontal gradient of the frame while convolution with h2 gives the vertical gradient. These are then combined to find the magnitude of the gradient at all points in the frame.

x = x HORIZ 2 + x VERT 2 x = x HORIZ 2 + x VERT 2 size 12{ lline nabla x rline = sqrt { { size 24{ left ( nabla x_ ital "HORIZ" right )} } rSup { size 8{2} } + { size 24{ left ( nabla x_ ital "VERT" right )} } rSup { size 8{2} } } } {}
(4)

The gradient magnitudes are then thresholded, and any gradient magnitude greater than the threshold is recognized to be an edge. Thus the result is a matrix of zeros and ones, where a 1 indicates that that pixel is part of an edge, and a 0 indicates it is not part of an edge. For our system, a threshold of 125 gives satisfactory results and recognizes only sharp edges.

Illustrative example

Below you can see a frame from Punch Drunk Love as well as the result from the edge detection method. For illustration purposes, the detected edges are displayed in white. The four vertical white lines are there to show the different regions of the screen that are eventually used to decide which region has the most edges in it.

Content actions

Give feedback:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks