Introduction (Shree K. Nayar, Columbia University)
This lecture focuses on edge detection, a fundamental concept in computer vision, specifically using the gradient operator. Edges are crucial features in images, representing rapid changes in intensity.
1D Edge Detection
- Definition of an Edge: An edge is a rapid change in image intensity within a small region.
- Example: A 1D signal, , with a rising edge (intensity increases) and a falling edge (intensity decreases).
- Calculus Connection: The derivative of a continuous function represents the amount of change in the function. Therefore, the first derivative can be used to detect edges.
- First Derivative Response:
- For a constant intensity region, the first derivative, , is zero.
- At a rising edge, the first derivative has a positive peak (local maximum).
- At a falling edge, the first derivative has a negative peak (local minimum).
- Finding Edges: The local extrema (maxima and minima) of the first derivative indicate the locations of edges.
- Absolute Value for Simplicity By taking the absolute value of the first derivative, , both rising and falling edges produce positive peaks.
- The magnitude of the derivative is used to determine the location and strength of the edge.
2D Edge Detection
- Partial Derivatives: For a 2D image, , we use partial derivatives (or “pure” derivatives) to represent the change in intensity along each dimension (x and y).
- The Gradient Operator (∇):
- The gradient operator, denoted by (also called “Del”), is a vector composed of the partial derivatives.
- The gradient represents the direction of the most rapid change in intensity.
- Examples of Gradient Vectors:
- Vertical Edge: (change only in the x-direction)
- Horizontal Edge: (change only in the y-direction)
- Tilted Edge: (change in both x and y directions)
Gradient as an Edge Detector
- Gradient Magnitude: The magnitude of the gradient vector, denoted as S, represents the strength of the edge:
- Gradient Orientation: The orientation (angle) of the edge, denoted as θ (measured with respect to the horizontal axis), is given by:
- Gradient, magnitude of the image and the orientation gives complete information of the edge.
Discrete Gradient Operator
- Finite Difference Approximations: In digital images (which are discrete), we approximate derivatives using finite differences. Finite difference approximations can be written as:
- Convolution Implementation: These finite difference approximations can be implemented as convolution operations with specific kernels. Finite difference approximations are implemented with Convolution, the below filters represents convolution filters, where the flips are already applied:
Comparing Gradient Operators The gradient operator’s are compared as:
| Gradient | Roberts | Prewitt | Sobel(3x3) | Sobel(5x5) |
|---|---|---|---|---|
- Roberts Operator: A very small (2x2) operator. Provides good localization but is highly sensitive to noise.
- Prewitt Operator: A 3x3 operator.
- Sobel Operator (3x3): A commonly used 3x3 operator. It’s essentially a smoothed version of a smaller derivative operator, making it less sensitive to noise.
- Sobel Operator (5x5): A larger version of the Sobel operator, providing even more noise resilience at the cost of slightly poorer localization.
- The operators increases in extent and serves to reduce noise, larger the operator, less noise sensitive and good detection, but poor localization.
Gradient Using Sobel Filter
- The video shows an example of applying the 3x3 Sobel operator to the Lena image. The results are:
- : The derivative with respect to x.
- : The derivative with respect to y.
- Gradient Magnitude: The combined strength of the edge, highlighting edges.
Edge Thresholding
- Need for Thresholding: After calculating the gradient magnitude, a thresholding step is necessary to decide which pixels are truly part of an edge.
- Standard Thresholding (Single Threshold, T):
- If : Definitely not an edge.
- If : Definitely an edge.
- Hysteresis Thresholding (Two Thresholds, and , where ):
- If : Definitely not an edge.
- If : Definitely an edge.
- If : The pixel is an edge if a neighboring pixel is definitely an edge (using contextual information). This helps to connect broken edge segments.
Sobel Edge Detector (Example)
- The video shows the final thresholded edge map for the Lena image, demonstrating the result of the Sobel operator followed by thresholding. The teacher emphasizes that this results in a “scattered set of edges” and that further processing is often needed to connect them into clean boundaries, which will be covered in later lectures.
- The video shows an example by taking the Lena Image, and applying gradient operator, first derivative with respect to x and y, and finally, a thersholded edge map.