Я думаю, вы можете получить свой center
из макс. Регионов the distance map
следующим образом:
left: your origin image
mid: distmap, blur for the border, purple for the center, green for moments center
right: display in color
# 2018.09.23 12:00 (CST)
import numpy as np
import cv2
img = cv2.imread("masks.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
th, threshed = cv2.threshold(gray, 100, 255, cv2.THRESH_OTSU|cv2.THRESH_BINARY_INV)
dist = cv2.distanceTransform(threshed, cv2.DIST_C, 3, None, cv2.CV_32F)
## Notice, I just find the first max of the max-regions in the distmap
xid = dist.argmax()
nh, nw = img.shape[:2]
cx = xid%nw
cy = xid//nw
print((cx, cy))
cv2.circle(img, (cx,cy), 5, purple, -1, cv2.LINE_AA)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()