I would like to get the center point(x,y) of a figure created by a set of points.

How do I do this?

If you mean centroid, you just get the average of all the points.

x = [p[0] for p in points]
y = [p[1] for p in points]
centroid = (sum(x) / len(points), sum(y) / len(points))

If the set of points is a numpy array positions of sizes N x 2, then the centroid is simply given by:

centroid = positions.mean(axis=0)

It will directly give you the 2 coordinates a a numpy array.

In general, numpy arrays can be used for all these measures in a vectorized way, which is compact and very quick compared to for loops.

I assume that a point is a tuple like (x,y), so you can use zip to join the x’s and y’s. Then using the min and max of x and y’s, you can determine the center point.

center=(max(x)+min(x))/2., (max(y)+min(y))/2.

Sample output

Points in an array : [(411, 148), (304, 148), (357, 241)]
x:(411, 304, 357)
y:(148, 148, 241)
center: (357.5, 194.5)