Coordinate order from left to right

How can I try to arrange the points of an irregular array in the upper left to left, for example, in the image below?

Points ordered top left to bottom right

Methods I reviewed:

  • calculate the distance of each point in the upper left corner of the image (Pythagorean theorem), but apply some kind of weighting to the coordinate Yin an attempt to determine the priorities of the points on the same " row", for example.distance = SQRT((x * x) + (weighting * (y * y)))

  • sort points into logical lines, and then sort each line.

Part of the difficulty is that I do not know how many rows and columns will be present in the image, combined with the unevenness of the array of points. Any advice would be greatly appreciated.

+4
source share
1 answer

:
1. (p)
2. x y , ,     x = int(x/n)*n, y = int(y/m)*m n, m 3. m, n , . m, , p .

max(x) - min(x). . X Y .

, (X Y), . .

0

All Articles