cs, _ = cv2.findContours(BW.astype('uint8'), mode=cv2.RETR_LIST, method=cv2
    .CHAIN_APPROX_SIMPLE)
filledI = np.zeros(BW.shape[0:2]).astype('uint8')
convexI = np.zeros(BW.shape[0:2]).astype('uint8')
i = 0
c = cs[i]
m = cv2.moments(c)
Area = m['m00']
Perimeter = cv2.arcLength(c, True)
BoundingBox = cv2.boundingRect(c)
Centroid = m['m10'] / m['m00'], m['m01'] / m['m00']
EquivDiameter = np.sqrt(4 * Area / np.pi)
Extent = Area / (BoundingBox[2] * BoundingBox[3])
cv2.drawContours(filledI, cs, i, color=255, thickness=-1)
regionMask = filledI == 255
FilledArea = np.sum(regionMask)
PixelIdxList = regionMask.nonzero()
ConvexHull = cv2.convexHull(c)
ConvexArea = cv2.contourArea(ConvexHull)
Solidity = Area / ConvexArea
cv2.drawContours(convexI, [ConvexHull], -1, color=255, thickness=-1)
centre, axes, angle = cv2.fitEllipse(c)
MAJ = np.argmax(axes)
MIN = 1 - MAJ
MajorAxisLength = axes[MAJ]
MinorAxisLength = axes[MIN]
Eccentricity = np.sqrt(1 - (axes[MIN] / axes[MAJ]) ** 2)
Orientation = angle
EllipseCentre = centre
MaxIntensity = np.max(img[regionMask])
MinIntensity = np.min(img[regionMask])
MeanIntensity = np.mean(img[regionMask], axis=0)
PixelValues = img[regionMask]
Python OpenCV — поиск черных областей в двоичном изображении