I'm using Opencv to do some morphological operations on an image:
but it joins some of the letters together creating problems when I detect it's contours. For example:
Is there some tweaking I can do wih my code to fix this or will I have to do this a different way?(but it has to be a closing algorithm or function because it is pretty helpful in preprocessing).
My code I am using is as below:
kernel = np.ones((5,5),np.uint8)
opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel)
closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel)
Here is workable solution:
During the two first steps the image is binarize and reverse in order to make the letters appear has white over black.
Then during the next step each letter become a labelized region.
The final step consist for each label value to find the area in the image that correspond to it, process the external contour of that area and "draw" it in the output image.
Hope it helps.