# Is the Canny algorithm enough for creating a feature descriptor image for input to an SVM?

I retrieve contours from images by using the Canny algorithm.

Is this enough preprocessing to have a descriptor image for input into an SVM to find similarities?

Do I need other features like elongation, perimeter, area?

I am asking about this because I was inspired by this example. I have given my image in greyscale first, in the Canny algorithm style second, and in both cases my confusion matrix had plenty of 0s like precision, recall, f1-score, support measure, etc.

Yes and no.

Yes, the binary image output from the Canny edge detector is a feature set.

As the Feature (computer vision) wiki page describes:

... an edge can be represented as a boolean variable in each image point that describes whether an edge is present at that point. Alternatively, we can instead use a representation which provides a certainty measure instead of a boolean statement of the edge's existence and combine this with information about the orientation of the edge.

What you have is the former; a boolean variable for every pixel in the image, true where there is an edge. A Hough Transform would be an example of a method to get the latter; edges represented by measure and orientation.

If you take the same image and convert it to edges, the feature set will be the same. If you take two different images and convert them to edges, the feature set will likely be different. So yes, you can model an image using the Canny edge detector alone.

Now, no, the binary image output from the Canny edge detector is probably not a very useful feature set.

Consider a single training image of an apple and three test images: an apple, an orange, and a banana. By shape, what we are focusing on by focusing on the Canny edge detector, we would expect the test apple to be most closely related to the training apple, the orange second, and the banana last.

In a candy land of image analysis, where the images are all perfectly composed, their edges could line up such that the apples edges overlap exactly, the orange's edge overlaps a lot with the apple, and the banana's edges only overlap for the few pixels they intersect. However, in reality you are probably comparing images of different apples with different backgrounds and different composition. Imagine the test apple is shifted one pixel down and to the right, now it hardly overlaps with the training apple at all; the orange will be a better match. In this example, the binary image output from the Canny edge detector is not a robust feature descriptor.

Think of the Canny edge detector algorithm as a transformation of the image. It can be a useful step in getting to a powerful set of features which describe your image, but it itself is not usually a powerful feature descriptor.

So, what would be a powerful feature descriptor?

..well you didn't ask that ;)

• Canny produces very good edges. BUT the differential step is very sensitive to slight changes, if you run canny on a video of a static scene you will get different edges on each frame – Martin Beckett Jan 14 '13 at 4:34