<< Chapter < Page Chapter >> Page >

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 (h 1 and h 2 ) using the following formula:

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 \) } } } {}

Where:

x = gradient size 12{ nabla x=` ital "gradient"} {}
x = image size 12{x=` ital "image"} {}

h 1 = 1 0 1 2 0 2 1 0 1 size 12{h_1= left [ matrix { - 1 {} # 0 {} # 1 {} ##- 2 {} # 0 {} # 2 {} ## - 1 {} # 0 {} # 1{}} right ]} {} and h 2 = 1 2 1 0 0 0 1 2 1 size 12{h_2= left [ matrix { 1 {} # 2 {} # 1 {} ##0 {} # 0 {} # 0 {} ## - 1 {} # - 2 {} # - 1{}} right ]} {}

The result of convolution with h 1 gives the horizontal gradient of the frame while convolution with h 2 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 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} } } } {}

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.

Original frame

Detected edges

White indicates an edge. The vertical bars are illustrative of how the frame could be segmented for analysis. Note that the area of interest is far to the left of the frame, not in the middle.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Adaptive region of interest for video. OpenStax CNX. Dec 14, 2010 Download for free at http://cnx.org/content/col11256/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Adaptive region of interest for video' conversation and receive update notifications?

Ask