class CannyEdgeDetector extends AnyRef
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.
- Alphabetic
- By Inheritance
- CannyEdgeDetector
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new CannyEdgeDetector()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getEdgesImage(): BufferedImage
Obtains an image containing the edges detected during the last call to the process method.
Obtains an image containing the edges detected during the last call to the process method. The buffered image is an opaque image of type BufferedImage.TYPE_INT_ARGB in which edge pixels are white and all other pixels are black.
- returns
an image containing the detected edges, or null if the process method has not yet been called.
-
def
getGaussianKernelRadius(): Float
The radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation.
The radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation. The default value is 16.
- returns
the Gaussian kernel radius in pixels
-
def
getGaussianKernelWidth(): Int
The number of pixels across which the Gaussian kernel is applied.
The number of pixels across which the Gaussian kernel is applied. The default value is 16.
- returns
the radius of the convolution operation in pixels
-
def
getHighThreshold(): Float
The high threshold for hysteresis.
The high threshold for hysteresis. The default value is 7.5.
- returns
the high hysteresis threshold
-
def
getLowThreshold(): Float
The low threshold for hysteresis.
The low threshold for hysteresis. The default value is 2.5.
- returns
the low hysteresis threshold
-
def
getSourceImage(): BufferedImage
The image that provides the luminance data used by this detector to generate edges.
The image that provides the luminance data used by this detector to generate edges.
- returns
the source image, or null
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
isContrastNormalized(): Boolean
Whether the luminance data extracted from the source image is normalized by linearizing its histogram prior to edge extraction.
Whether the luminance data extracted from the source image is normalized by linearizing its histogram prior to edge extraction. The default value is false.
- returns
whether the contrast is normalized
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- def process(): Unit
-
def
setContrastNormalized(contrastNormalized: Boolean): Unit
Sets whether the contrast is normalized
Sets whether the contrast is normalized
- contrastNormalized
true if the contrast should be normalized, false otherwise
-
def
setEdgesImage(edgesImage: BufferedImage): Unit
Sets the edges image.
Sets the edges image. Calling this method will not change the operation of the edge detector in any way. It is intended to provide a means by which the memory referenced by the detector object may be reduced.
- edgesImage
expected (though not required) to be null
-
def
setGaussianKernelRadius(gaussianKernelRadius: Float): Unit
Sets the radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation.
Sets the radius of the Gaussian convolution kernel used to smooth the source image prior to gradient calculation.
- returns
a Gaussian kernel radius in pixels, must exceed 0.1f.
-
def
setGaussianKernelWidth(gaussianKernelWidth: Int): Unit
The number of pixels across which the Gaussian kernel is applied.
The number of pixels across which the Gaussian kernel is applied. This implementation will reduce the radius if the contribution of pixel values is deemed negligable, so this is actually a maximum radius.
- gaussianKernelWidth
a radius for the convolution operation in pixels, at least 2.
-
def
setHighThreshold(threshold: Float): Unit
Sets the high threshold for hysteresis.
Sets the high threshold for hysteresis. Suitable values for this parameter must be determined experimentally for each application. It is nonsensical (though not prohibited) for this value to be less than the low threshold value.
- threshold
a high hysteresis threshold
-
def
setLowThreshold(threshold: Float): Unit
Sets the low threshold for hysteresis.
Sets the low threshold for hysteresis. Suitable values for this parameter must be determined experimentally for each application. It is nonsensical (though not prohibited) for this value to exceed the high threshold value.
- threshold
a low hysteresis threshold
-
def
setSourceImage(image: BufferedImage): Unit
Specifies the image that will provide the luminance data in which edges will be detected.
Specifies the image that will provide the luminance data in which edges will be detected. A source image must be set before the process method is called.
- image
a source of luminance data
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )