|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttools.CannyEdgeDetector
public class CannyEdgeDetector
This software has been released into the public domain. Please read the notes in this source file for additional information.
This class provides a configurable implementation of the Canny edge detection algorithm. This classic algorithm has a number of shortcomings, but remains an effective tool in many scenarios. This class is designed for single threaded use only.
Sample usage:
//create the detector
CannyEdgeDetector detector = new CannyEdgeDetector();
//adjust its parameters as desired
detector.setLowThreshold(0.5f);
detector.setHighThreshold(1f);
//apply it to an image
detector.setSourceImage(frame);
detector.process();
BufferedImage edges = detector.getEdgesImage();
For a more complete understanding of this edge detector's parameters consult an explanation of the algorithm.
Constructor Summary | |
---|---|
CannyEdgeDetector()
Constructs a new detector with default parameters. |
Method Summary | |
---|---|
java.awt.image.BufferedImage |
getEdgesImage()
Obtains an image containing the edges detected during the last call to the process method. |
float |
getGaussianKernelRadius()
The radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation. |
int |
getGaussianKernelWidth()
The number of pixels across which the Gaussian kernel is applied. |
float |
getHighThreshold()
The high threshold for hysteresis. |
float |
getLowThreshold()
The low threshold for hysteresis. |
java.awt.image.BufferedImage |
getSourceImage()
The image that provides the luminance data used by this detector to generate edges. |
boolean |
isContrastNormalized()
Whether the luminance data extracted from the source image is normalized by linearizing its histogram prior to edge extraction. |
void |
process()
|
void |
setContrastNormalized(boolean contrastNormalized)
Sets whether the contrast is normalized |
void |
setEdgesImage(java.awt.image.BufferedImage edgesImage)
Sets the edges image. |
void |
setGaussianKernelRadius(float gaussianKernelRadius)
Sets the radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation. |
void |
setGaussianKernelWidth(int gaussianKernelWidth)
The number of pixels across which the Gaussian kernel is applied. |
void |
setHighThreshold(float threshold)
Sets the high threshold for hysteresis. |
void |
setLowThreshold(float threshold)
Sets the low threshold for hysteresis. |
void |
setSourceImage(java.awt.image.BufferedImage image)
Specifies the image that will provide the luminance data in which edges will be detected. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CannyEdgeDetector()
Method Detail |
---|
public java.awt.image.BufferedImage getSourceImage()
getSourceImage
in interface AnalysisFilter
public void setSourceImage(java.awt.image.BufferedImage image)
setSourceImage
in interface AnalysisFilter
image
- a source of luminance datapublic java.awt.image.BufferedImage getEdgesImage()
public void setEdgesImage(java.awt.image.BufferedImage edgesImage)
edgesImage
- expected (though not required) to be nullpublic float getLowThreshold()
public void setLowThreshold(float threshold)
threshold
- a low hysteresis thresholdpublic float getHighThreshold()
public void setHighThreshold(float threshold)
threshold
- a high hysteresis thresholdpublic int getGaussianKernelWidth()
public void setGaussianKernelWidth(int gaussianKernelWidth)
gaussianKernelWidth
- a radius for the convolution operation in
pixels, at least 2.public float getGaussianKernelRadius()
public void setGaussianKernelRadius(float gaussianKernelRadius)
public boolean isContrastNormalized()
public void setContrastNormalized(boolean contrastNormalized)
contrastNormalized
- true if the contrast should be normalized,
false otherwisepublic void process()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |