How can I find the coordinates of the midpoints of the objects in the picture?

asked 2018-06-06 16:16:51 -0600

image description

import numpy as np import cv2 img = cv2.imread('ort2.jpg', 1) kernel = np.ones((5,5),np.uint8) mblr13= cv2.medianBlur(img,7) gray = cv2.cvtColor(mblr13, cv2.COLOR_BGR2GRAY) mblr3= cv2.medianBlur(gray,7) gray_blur = cv2.GaussianBlur(mblr3, (27, 27), 0) img3 = (255-gray_blur) img4 = cv2.adaptiveThreshold(img3 , 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,13,0) thresh = cv2.medianBlur(img4,9) thresh=(255-thresh) erode1 =cv2.dilate(thresh,kernel,iterations = 1) closing1 = cv2.morphologyEx(erode1, cv2.MORPH_CLOSE, kernel) erode1 =cv2.dilate(closing1,kernel,iterations = 1) closing1 = cv2.morphologyEx(erode1, cv2.MORPH_CLOSE, kernel) cv2.imshow('frame',closing1) cv2.imwrite('sonc.jpg',closing1) cv2.waitKey(0) cv2.destroyAllWindows()

image description

edit retag flag offensive close merge delete