Remove spots in a black/white text image
Posted: 2017-12-26T09:07:59-07:00
Hi.
I have seen similar threads but I didn't manage to get what I wanted out of them.
Here is an example: https://i.imgur.com/REXnLuQ.png
I'd like to remove the spots such that only the text remains, and be able to choose a number of pixels threshold. Here the biggest spot has around 30 pixels but other images may have larger spots that I want to remove so I want to be able to change this value.
I tried this command: convert input.png -morphology Close Disk ouput.png
But besides the spots it also remove parts of the letters.
This command seems to do the job for small spots with less than 5 pixels, but I don't know how to modify it for larger spots: convert input.png -verbose -negate -morphology Thinning "4x4:0,0,0,0, 0,1,1,0, 0,1,1,0, 0,0,0,0" -morphology Thinning:5 LineEnds -morphology Thinning "3:0,0,0, 0,1,0, 0,0,0" -negate output.png
Also tried this method (viewtopic.php?p=132613#p132613) but the result is a mess.
Thank you in advance.
I have seen similar threads but I didn't manage to get what I wanted out of them.
Here is an example: https://i.imgur.com/REXnLuQ.png
I'd like to remove the spots such that only the text remains, and be able to choose a number of pixels threshold. Here the biggest spot has around 30 pixels but other images may have larger spots that I want to remove so I want to be able to change this value.
I tried this command: convert input.png -morphology Close Disk ouput.png
But besides the spots it also remove parts of the letters.
This command seems to do the job for small spots with less than 5 pixels, but I don't know how to modify it for larger spots: convert input.png -verbose -negate -morphology Thinning "4x4:0,0,0,0, 0,1,1,0, 0,1,1,0, 0,0,0,0" -morphology Thinning:5 LineEnds -morphology Thinning "3:0,0,0, 0,1,0, 0,0,0" -negate output.png
Also tried this method (viewtopic.php?p=132613#p132613) but the result is a mess.
Thank you in advance.