I am trying to separate lines and circles of the image below using morphology. For circle I did it well, but for lines I really do not know how to do.
The Image Sample:
The code I’ve tried:
image = cv2.imread('sample.png')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = otsuThresholding(image) # Function that threshold the image
structuringElement = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (18, 18))
imageErode = cv2.erode(image, structuringElement)
openingCircles = cv2.dilate(imageErode, structuringElement)
plt.title("Circles")
plt.imshow(openingCircles, 'gray', vmax=255, vmin=0)
plt.show()
I already tried to remove the circles of the original image and then dilate, but it not works well, it ends up with holes in the middle of the lines, or it becomes so thick that it joins them together.