hamed
hamed

Reputation: 598

Classifying lines with opencv

I'm working on an image classification project, I've extracted curved lines from image using edge-detection, and need to classify them based on their curvature.

For example in the image below there are 3 kinds of line, the left line has a good curvature, the middle one has a not-bad curvature, and the right line has a very-bad curvature.

curves

Thanks for your help

Upvotes: 6

Views: 1631

Answers (2)

marcos.nieto
marcos.nieto

Reputation: 374

If you are working with images, you can know whether a shape like the ones you've shown contain "smooth" or "sharp" edges. You can compute the eigenvalues and eigenvectors of the structural matrix (or image tensor matrix). For pixels belonging to a straight or smooth edge, one of the eigenvalues would be much larger than the other. In case the pixel is a corner or curvy point, both eigenvalues will probably be large and similar. Then I suggest to measure these features on the pixels of your shapes and train a classifier according to your needs.

You can find more details about such things almost elsewhere, although I can give you the reference of my own PhD, take a look to section 2.4.2 http://oa.upm.es/4837/1/MARCOS_NIETO_DONCEL.pdf

Best regards!

Upvotes: 6

krzych
krzych

Reputation: 2176

I see few possible measures to clasify:

Try approximate line with some approx eps then check how many segments approximate line, less segments the better line is. (This can make problems in most left case, when line contains from few segments)

Check bounding box size, less size better line

Check convexity defects.

Upvotes: 4

Related Questions