1 | initial version |
I finally ended up inverting the edges found with the canny procedure and applying findContours on that, to cut on the number of steps, it roughly looks like that :
edge = cv2.Canny(img_gray, CANNY_THRSH_LOW, CANNY_THRSH_HIGH, apertureSize=5)
kern = np.ones((5, 5))
# dilatation connects most of the disparate edges
edge = cv2.dilate(edge, kern)
# invert edges to create one big water blob
edge_inv = np.zeros((img_gray.shape), np.uint8)
edge_inv.fill(255)
edge_inv = edge_inv - edge
contours0, hierarchy0 = cv2.findContours(edge_inv.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
2 | No.2 Revision |
I finally ended up inverting the edges found with the canny procedure and applying findContours on that, to cut on the number of steps, it steps.
It roughly looks like that :
edge = cv2.Canny(img_gray, CANNY_THRSH_LOW, CANNY_THRSH_HIGH, apertureSize=5)
kern = np.ones((5, 5))
# dilatation connects most of the disparate edges
edge = cv2.dilate(edge, kern)
# invert edges to create one big water blob
edge_inv = np.zeros((img_gray.shape), np.uint8)
edge_inv.fill(255)
edge_inv = edge_inv - edge
contours0, hierarchy0 = cv2.findContours(edge_inv.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)