Edges and Contours– Chapter 7

Presentation on theme: "Edges and Contours– Chapter 7"— Presentation transcript:

Edges and Contours– Chapter 7
continued

Edge detection All of the previously studied edge detection filters worked on finding local gradients (1st derivative) As such, all had to make decisions regarding the actual existence of an edge based on local information

Sobel edges – threshold on magnitude

Sobel edges – threshold on magnitude
The preceding images were edge-detected with a Sobel operator then binarized with various thresholds The overall trend is predictable but the individual results are not This threshold dependency is the curse of image processing Difficult to isolate “real” edges Difficult to find accurate edge location We need smarter algorithms

Scale space processing
One method of dealing with the threshold dependency is through scale-space processing An image is processed at various scales (sizes/resolution) revealing different sets of features at each scale Features common to all [or many] sets are deemed “important”

The Gaussian Pyramid Select a set of Gaussian filter parameters (sigma and width) and blur the image Save the image Reduce it’s size by subsampling (eliminating every other row/column) Do it again

The Gaussian Pyramid You end up with a series of images (a pyramid) each exposing different features Coarse features at the top of the pyramid Fine features at the bottom You can now use the coarse features to select where to concentrate your processing of the fine features

Better (different) algorithms
Another method of dealing with the threshold dependency is through more complex algorithms

A better kernel The Sobel mask is a derivative mask (computes the weighted difference of neighborhood pixels) So is the Laplacian (negative in the middle, positive around the rest) From calculus: the 2nd derivative of a signal is zero when the derivative magnitude is extremal

A better kernel Combining these observations we can derive the Laplacian-Gaussian filter due to Marr and Hildreth Also known as a DoG (Difference of Gaussians) because it can be approximated by subtracting two Gaussian kernels of same width and differing sigmas

The Gaussian kernel Sigma 1.6, Filter Width 15

The Laplacian-Gaussian kernel
Bypassing the math and jumping to the results of applying the rules of calculus… Similar in form to the Gaussian kernel

The Laplacian-Gaussian kernel
In 1 dimension… Can be approximated by difference of two Gaussians

The Laplacian-Gaussian kernel
Convolution with this kernel results in edge magnitudes of both positive and negative values We’re interested in where the sign changes occur (the zero crossing) These are where the edges are (recall the calculus result)

Sobel vs. Laplacian-Gaussian
L-G does not detect as much “noise” as Sobel – why not?

Still something missing…
What are we ignoring in the following edge detection processes? Gaussian filter Sobel edge detection Threshold based binarization of Sobel magnitude And Laplacian-Gaussian filter Zero crossing detection

We need a smarter algorithm
We merely selected each edge based on its magnitude and zero-crossing We completely ignored its immediate surroundings Why is this bad? Detects edges we don’t want Prone to noise Prone to clutter Doesn’t detect edges we do want Weak magnitude edges are thresholded (thresheld?) away We need a smarter algorithm!

The Canny edge detector
John Canny – MIT 1986 Developed a process (series of steps) for identifying edges in an image Gaussian smoothing of input image Local derivative operator to detect edge candidates Removal of edges that are clustered around a single location Adaptive thresholding algorithm for final edge selection

Concepts Gaussian smooth original image Local derivative operator
Reduce the effects of noise Local derivative operator Simple neighbor pixel subtraction to detect gradients (1st derivative) Non-maximal suppression Thin out the edges around a given point Threshold Use two thresholds combined with spatial continuity

Spatial continuity aka contour following
Apply the high threshold to get “obvious” edges Search for a neighboring edge above the low threshold in the direction of the strong edge We’re using a strong edge as an anchor point for a contour of weak and strong edges – known as Hysteresis

Canny results With very conservative high/low thresholds

Results All edges Weak edges Contours Strong edges

Summary Through more complex processing we arrive at a set of edges in which we have confidence Minimal reliance on thresholds The cost is complex (slow, memory intensive) processing We must trade resources for accuracy!

Sobel, Prewitt, Roberts, Kirsch, Nevatia-Babu Plugins->FeatureJ->Edges Canny implementation

Edge Sharpening An process for making an image look “better”
In this case “better” means “sharper” The general approach is to amplify the high-frequency components (the edges) to create a “perceived” sharpness

Method 1 – subtract 2nd derivative
This causes a step edge to undershoot at the bottom and overshoot at the top The Laplacian works well for the 2nd derivative

ImageJ Note that this is difficult to do in ImageJ since the convolution operation clamps negative pixel values to 0

Unsharp mask Steps Subtract a Gaussian-smoothed version of the image from the original creating a mask Add a weighted version of the mask to the original image