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:
Where:
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.
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 |
|---|
![]() |






