Ask Your Question

Is there any way to thin out the characters after Otsu thresholding?

asked 2019-04-24 08:50:10 -0500

wdesert gravatar image

updated 2019-04-24 09:24:00 -0500


I am trying to segment all the characters (see the image below) and there is one issue I still can't solve. THRESH_OTSU works the best with the only exception that it merges some characters.

When I tried to use adaptive thresholding, there was no problem with character merging but I was unable to control the parameters so that it could work for most images.

I know that some combinations of erosion and dilation might work in such cases. Trouble is, even though the characters get thinner as a result of erosion, the areas between the characters only increase. Probably, I am misusing/misunderstanding erosion.

Thanks in advanced for any suggestions.

image description

image description Here's the source image.

image description Unlike the more classical case of car number plates, the font is often black on a light background. This is why I have to count the number of contours or rects returned by minAreaRect to invert the image in such cases.

edit retag flag offensive close merge delete


could you add the original images

sturkmen gravatar imagesturkmen ( 2019-04-24 09:12:09 -0500 )edit

@sturkmen, sure. Added two sources images

wdesert gravatar imagewdesert ( 2019-04-24 09:24:08 -0500 )edit

have you tried segmenting with kmeans clustering? adjusting the number of clusters might give you the segmentation you want

blooper98 gravatar imageblooper98 ( 2019-04-24 12:18:30 -0500 )edit

You can skeletonize the image, to thin it out:

sjhalayka gravatar imagesjhalayka ( 2019-04-24 20:56:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-04-24 14:16:53 -0500

Would template matching be an option for you? When I set up a template around the first zero, and searched in the remainder of the image, the 2nd zero was found with a high matching score.

image description

edit flag offensive delete link more


I haven't tried template matching. Do I understand correctly, I can use a set of letters and digits and templates and search for them?

I guess that it will not work well for skewed images

wdesert gravatar imagewdesert ( 2019-04-24 22:08:38 -0500 )edit

Yes, template matching is sensitive to scale and rotation. But if your digits are upright and consistent scale, template matching works well.

Chris gravatar imageChris ( 2019-04-25 07:32:53 -0500 )edit

Question Tools

1 follower


Asked: 2019-04-24 08:50:10 -0500

Seen: 120 times

Last updated: Apr 24 '19