com.pearsoneduc.ip.op
Class CannyEdgeOp

java.lang.Object
  |
  +--com.pearsoneduc.ip.op.StandardGreyOp
        |
        +--com.pearsoneduc.ip.op.CannyEdgeOp

public class CannyEdgeOp
extends StandardGreyOp

Performs Canny edge detection on an image.

Version:
1.0 [1999/07/30]
Author:
Nick Efford

Field Summary
static int ABS_MAGNITUDES
           
static int SQRT_MAGNITUDES
           
 
Constructor Summary
CannyEdgeOp(float size)
          Creates a CannyEdgeOp with the specified Gaussian filter size.
CannyEdgeOp(float size, int low, int high)
          Creates a CannyEdgeOp with the specified Gaussian filter size and a pair of thresholds.
CannyEdgeOp(float size, int low, int high, int calcMethod)
          Creates a CannyEdgeOp with the specified Gaussian filter size, thresholds and gradient magnitude calculation method.
 
Method Summary
protected  void applyHighThreshold(java.awt.image.BufferedImage image)
          Generates an edge map by applying a single threshold to gradient magnitude data.
protected  void computeGradient(java.awt.image.BufferedImage image)
          Computes gradient magnitude and orientation in the specified image.
 java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
          Performs Canny edge detection on an image.
 float getFilterSize()
           
 java.awt.image.BufferedImage getGradientMagnitudeImage()
           
 java.awt.image.BufferedImage getGradientOrientationImage()
           
 int getHighThreshold()
           
 int getLowThreshold()
           
 int getMagnitudeCalculationMethod()
           
protected  void performHysteresisThresholding(java.awt.image.BufferedImage image)
          Generates an edge map by hysteresis thresholding.
protected  void performNonMaximalSuppression()
          Peforms non-maximal suppression of gradient magnitude data.
protected  boolean trace(int x, int y, java.awt.image.WritableRaster raster)
          Recursively tracks edges between strong edge pixels.
 
Methods inherited from class com.pearsoneduc.ip.op.StandardGreyOp
checkImage, createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQRT_MAGNITUDES

public static final int SQRT_MAGNITUDES

ABS_MAGNITUDES

public static final int ABS_MAGNITUDES
Constructor Detail

CannyEdgeOp

public CannyEdgeOp(float size)
Creates a CannyEdgeOp with the specified Gaussian filter size. Gradient data will not be thresholded.
Parameters:
size - standard deviation of Gaussian

CannyEdgeOp

public CannyEdgeOp(float size,
                   int low,
                   int high)
Creates a CannyEdgeOp with the specified Gaussian filter size and a pair of thresholds. If the thresholds are equal, ordinary thresholding of gradient data takes place; if they differ, hysteresis thresholding is used.
Parameters:
size - standard deviation of Gaussian
low - lower threshold
high - upper threshold

CannyEdgeOp

public CannyEdgeOp(float size,
                   int low,
                   int high,
                   int calcMethod)
Creates a CannyEdgeOp with the specified Gaussian filter size, thresholds and gradient magnitude calculation method. If the thresholds are equal, ordinary thresholding of gradient magnitude takes place; if they differ, hysteresis thresholding is used.
Parameters:
size - standard deviation of Gaussian
low - lower threshold
high - upper threshold
calcMethod - calculation method
Method Detail

getFilterSize

public float getFilterSize()
Returns:
size of Gaussian low pass filter used for smoothing.

getLowThreshold

public int getLowThreshold()
Returns:
lower threshold applied to gradient magnitudes.

getHighThreshold

public int getHighThreshold()
Returns:
upper threshold applied to gradient magnitudes.

getMagnitudeCalculationMethod

public int getMagnitudeCalculationMethod()
Returns:
gradient magnitude calculation method.

getGradientMagnitudeImage

public java.awt.image.BufferedImage getGradientMagnitudeImage()
Returns:
gradient magnitude image generated by last call to the filter() method.

getGradientOrientationImage

public java.awt.image.BufferedImage getGradientOrientationImage()
Returns:
gradient orientation image generated by last call to the filter() method.

filter

public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src,
                                           java.awt.image.BufferedImage dest)
Performs Canny edge detection on an image.
Parameters:
src - source image
dest - destination image, or null
Returns:
edge map or gradient magnitudes
Overrides:
filter in class StandardGreyOp

computeGradient

protected void computeGradient(java.awt.image.BufferedImage image)
Computes gradient magnitude and orientation in the specified image.
Parameters:
image - source image

performNonMaximalSuppression

protected void performNonMaximalSuppression()
Peforms non-maximal suppression of gradient magnitude data.

applyHighThreshold

protected void applyHighThreshold(java.awt.image.BufferedImage image)
Generates an edge map by applying a single threshold to gradient magnitude data.
Parameters:
image - destination image

performHysteresisThresholding

protected void performHysteresisThresholding(java.awt.image.BufferedImage image)
Generates an edge map by hysteresis thresholding.
Parameters:
image - destination image

trace

protected boolean trace(int x,
                        int y,
                        java.awt.image.WritableRaster raster)
Recursively tracks edges between strong edge pixels.
Parameters:
x - x coordinate of starting point
y - y coordinate of starting point
raster - edge map