Canny Edge Detector Implementation

This is an efficent implementation of the Canny edge detection algorithm in Java (see http://en.wikipedia.org/wiki/Canny_edge_detector) which I have released into the public domain.

It is implemented using a single Java class CannyEdgeDetector.java.

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 more information see the comments in the supplied code.

Examples

The following image was processed using the detector's default parameters.

source image
edges image

The short video below was created during the testing and optimization of this implementation. I chose a 'comic styled' video clip in the expectation that its stylization would be favourable to the algorithm. It is combined with a colour reduction algorithm derived from a linear-time clustering algorithm I have developed.

It demonstrates some of the weaknesses of the algorithm and my implementation of it. Note the absence of edges around the edges of the frame. This is the width of the convolution operation. Also observe the poor localization of the edges in some cases (eg. the edge of the shield). This is a consequence of using a relatively large radius for the Gaussian kernel.

Download the video file here: flv 1.7MB, wmv 470KB, mov 475KB.

I believe that the brevity of this clip and its non-commercial use constitutes fair use.