An edge is a set of pixels where image intensity or colour changes rapidly. It usually marks an object boundary.
An edge map is a binary image that marks the pixels judged to be edges. It supports segmentation, which groups pixels into image regions. It also supports feature detection, motion analysis and object selection.
Edge Profiles
An ideal step edge changes intensity at 1 position. A real boundary spreads across several pixels because of blur, sampling and the optical system.
- Step edge
Intensity changes from 1 nearly constant level to another. - Ramp edge
Intensity changes gradually across an interval. - Line edge
Intensity rises, then falls again across a narrow bright or dark band.
Texture, noise and gradual illumination can also produce local intensity changes. An edge detector must reject those changes when they do not represent a boundary.
First-Order Edge Detection
A first-order detector measures the rate of intensity change. It has 4 stages:
- Optional smoothing
Reduces noise before differentiation. - Horizontal and vertical derivatives
Measure change along the image axes. - Gradient magnitude
Measures the local edge strength. - Thresholding
Converts the strength image into a binary edge map.
Image Gradient
The image gradient is the vector of first partial derivatives at :
- image intensity at
- horizontal intensity derivative
- vertical intensity derivative
The gradient points towards the greatest intensity increase. Its direction is perpendicular to the edge.
is the gradient magnitude. It is the edge-strength response used for thresholding. is the gradient direction.
Discrete Derivatives
An image contains samples, not a continuous intensity function. A finite difference estimates a derivative by subtracting neighbouring pixel values.
The horizontal derivative compares pixels in 1 row. The vertical derivative compares pixels in 1 column. Pixel centres are 1 sample apart, so .
Difference Masks
A difference mask is a small spatial-filter kernel that subtracts neighbouring pixel values. The kernel moves over the image. At each position, its entries are multiplied by the covered pixels and summed. The sum is the derivative response.
The sign of a derivative depends on the mask direction. Reversing a mask reverses the sign. It does not change the gradient magnitude or the detected edge locations.
Forward Difference
A forward difference compares a pixel with its right or lower neighbour.
For horizontal values and , ordered from left to right, gives . A positive response means intensity increases to the right.
The response lies halfway between the 2 sampled pixels. It does not identify a single edge pixel.
Centred Difference
A centred difference compares the 2 neighbours around the current pixel.
The denominator is because the outer samples are 2 pixels apart. The response belongs to the centre pixel .
Gradient Operators
Raw differences amplify noise. Gradient operators combine a derivative with local averaging, which reduces that sensitivity.
Prewitt Operator
The Prewitt operator applies a centred difference across 3 parallel rows or columns. Each row or column has equal weight.
Sobel Operator
The Sobel operator is a Prewitt-like derivative with twice the weight on the centre row or column. The extra averaging usually reduces noise sensitivity.
Roberts Operator
The Roberts operator uses 2-point differences along the 2 diagonal directions. Its support is computationally small and highly sensitive to noise.
Thresholded Edge Maps
A gradient response exists at every pixel. Thresholding compares its magnitude with an edge-strength threshold . Pixels meeting the threshold become edges in the binary map.
- binary edge-map value
- minimum gradient magnitude accepted as an edge
- Low
Retains weak boundaries and false edges from noise or texture. - High
Rejects false edges and can remove weak object boundaries.
A Gaussian filter can smooth noise before differentiation. Smoothing also broadens real transitions.
Thick and Parallel Edges
Thresholding a blurred step can retain a band of pixels around 1 transition. The binary edge is thick.
A bright band has 1 rising boundary and 1 falling boundary. Its gradient magnitude has 2 peaks. Thresholding produces 2 parallel edges.
Second-Order Edge Detection
A second-order detector measures how quickly the gradient changes. It locates edges from a zero crossing, where its signed response changes between positive and negative values.
Laplacian
The Laplacian is the sum of the 2 second partial derivatives:
For a 1-dimensional signal with unit pixel spacing:
Applying the same estimate horizontally and vertically gives:
The -neighbour convolution kernel is:
A Laplacian response of at 1 pixel does not by itself locate an edge. A zero crossing requires a sign change between neighbouring responses. The sign-change direction identifies the darker and brighter sides.
Laplacian of Gaussian
The Laplacian amplifies noise. The Laplacian of Gaussian first smooths the image with a Gaussian filter, then applies the Laplacian:
- Gaussian kernel with standard deviation
- convolution
A larger rejects more noise and removes more fine edge detail. The LoG reduces false zero crossings but does not remove every response caused by texture.
Edge Sharpening
The negative Laplacian increases contrast around a rapid intensity change. Adding it to the original image sharpens the change:
With the -neighbour Laplacian, the combined convolution filter is:
Sharpening also amplifies noise. Apply it after denoising when necessary.
Worked Example
Laplacian Response
Find the -neighbour Laplacian response at a pivot value of with neighbours , , and .
Solution Reveal Hide
The response is .