Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 724
hamed Avatar asked Jun 25 '12 08:06

hamed


2 Answers

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!

like image 112
marcos.nieto Avatar answered Sep 24 '22 07:09

marcos.nieto


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.

like image 30
krzych Avatar answered Sep 20 '22 07:09

krzych