This applet compares several common edge detection algorithms and techniques, including Roberts Cross Operator, Prewitt Edge Detection Operator, and Sobel Edge Detection Operator. It also utilizes Gaussian Blur, Non-maximum Suppression, and Thresholding techniques. The user can select from a variety of files, and can also enter the path of a local file on the hard drive. Note: The Custom filename, and the Non-maximum Suppression may be inoperational.
BACKGROUND
The simplest Edge Detection methods rely on finding the first order differences between adjacent pixels. The most obvious way to implement this, is to find the x-change and y-change, and consolidate this information (as represented by the Simple algorithm). Robert's Cross Operator is more successful in that it takes both diagonals to calculate edges. Since edge detection is essentially the same as differentiating a function, the Prewitt Edge Detection Operator takes the gradient vector of a 3x3 area, with areas having a larger gradient vector being defined as "edges". Sobel Edge Detection Operator is very similar to Prewitt Edge Detection Operator, except that it takes into account the Gaussian Distribution to better define edges.
There are other ways to decrease erroneous pixels and enhance the clarity of edges. Gaussian Blur is the first step. This smoothes pixels and decreases the number of erroneous results. Mon-Maximum Suppression essentially finds the maximum value of each "line", and deletes the pixels that are not part of the maximum "line". This cleans up the image for a clearer edge. Lastly, Thresholding removes the pixels that are less than a certain value. This removes unwanted pixels, softer edges, and erroneous results.
IMPLEMENTATION
The edge detection operators can be represented as a "template", which simplifies the calculations in the java applet. For example, the simplest operator has the template:
| 2 | -1 |
| -1 | 0 |
This means: pixel(i,j) = 2*pixel(i,j) - pixel(i,j+1) - pixel(i+1,j).
Other Edge Detection Operators have templates for both the x and y components.
Roberts Cross Operator:
Template 1:
| 1 | 0 |
| 0 | -1 |
Template 2:
| 0 | 1 |
| -1 | 0 |
pixel(i,j) = maximum(template 1, template 2)
Prewitt Operator:
X-axis Template:
| 1 | 0 | -1 |
| 1 | 0 | -1 |
| 1 | 0 | -1 |
Y-axis Template:
| 1 | 1 | 1 |
| 0 | 0 | 0 |
| -1 | -1 | -1 |
pixel(i,j) = sqrt((x-axis template)^2 + (y-axis template)^2)
Sobel Operator:
X-axis Template:
| 1 | 0 | -1 |
| 2 | 0 | -2 |
| 1 | 0 | -1 |
Y-axis Template:
| 1 | 2 | 1 |
| 0 | 0 | 0 |
| -1 | -2 | -1 |
pixel(i,j) = sqrt((x-axis template)^2 + (y-axis template)^2)
For information about extraction and processing of images using java, see the Color Compare applet.
SOURCES
Naughton, Patrick and Herbert Schildt. Java2: The Complete Reference. Third Edition. Berkeley, CA: Mc-Graw-Hill, 1999.
Nixon, Mark and Alberto Aguado. Feature Extraction and Image Processing. Oxford: Newnes, 2002
Note: Some of the code has been copied from these sources