Mar-20-2019, 08:01 PM
Hey ichabod!
Thank you very much for your input, it helped a lot!
First, i defined similarity as deviation of y towards the group mean within a certain tolerance. As i do not need so precise, I defined as deviation towards the first element of the group within a certain tolerance.
I implemented it as you suggested - I first sort it according to y, then augment the list with a 4th, group common similarity value and use this as first search criteria. This group common similarity value, I defined to be the first value of such a group and to be updated if the difference exceeds a limit.
Thank you very much for your input, it helped a lot!
First, i defined similarity as deviation of y towards the group mean within a certain tolerance. As i do not need so precise, I defined as deviation towards the first element of the group within a certain tolerance.
I implemented it as you suggested - I first sort it according to y, then augment the list with a 4th, group common similarity value and use this as first search criteria. This group common similarity value, I defined to be the first value of such a group and to be updated if the difference exceeds a limit.
def sort_circles(circles, limit): circles = sorted(circles, key=lambda x: x[1]) old_y = circles[0][1] for (i,(x,y,r)) in enumerate(circles): if abs(old_y - y) > limit: old_y = circles[i][1] circles[i] = np.append(circles[i], old_y) circles = sorted(circles, key=lambda x: (x[3], x[0])) circles = [(x,y,r) for (x,y,r,z) in circles] return circles