Ask Your Question
1

Contour left of right?

asked 2015-10-22 05:15:15 -0600

zms gravatar image

Is there any method on earth that based on these contours, I know that the A contour is on the right of B contour? or vise versa as in the picture? image description I had been playing with the centroids and coordinate and it does not make sense so far from the result.

There is an idea that I think which is to draw a line base on the centroid at 45 degree toward (0,0) for both centroid and look at the y value crossing.

The question is how can I draw a line from a given centroid at 45 degree and manage to get the crossing point on Y axis. If looking at the first picture, it will not cross Y axis. AM I right? So mybe my idea is not working too.

edit retag flag offensive close merge delete

Comments

1

Your idea seems too complicated. It is easy to find the most left, right, top and bottom points of a given contour. Once you have retrieved them, you can apply rules to order your contours with sort() function. Check this post

LorenaGdL gravatar imageLorenaGdL ( 2015-10-22 05:44:33 -0600 )edit

i think this may be a clue.check deg value

   Point2f a ;
   Point2f b ;
   double deg = atan((b.y-a.y)/(b.x-a.x)) * 180 / PI;
sturkmen gravatar imagesturkmen ( 2015-10-22 06:02:19 -0600 )edit
1

First you need to define the labels of the contours, like B the small one and A the big one (like in your image), this you can get by contourArea, or using arcLength, then you need to sort the contours from left to right, and here you need to define what left means (based on the centroid, base on the x or y coordinates of its points, or any other criteria)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-10-22 07:17:03 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-10-26 03:24:33 -0600

zms gravatar image

OK noted ...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-22 05:15:15 -0600

Seen: 417 times

Last updated: Oct 22 '15