remove dots from picture before OCR

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
faboloso
Posts: 2
Joined: 2019-08-14T07:23:12-07:00
Authentication code: 1152

remove dots from picture before OCR

Post by faboloso »

Good morning,

I am new to the forum but I have been using ImageMagick for a while in python script in combination with OCR

Last time I used to remove lines from text and then OCR it

But for this project I am not sure which parameters to use. I hate to ask and not really asking for someone to spoon feed me but anyone can guide me a bit on which parameters I should use to get clear text / no dots or even white background (OCR still recognize it this way already for maybe 60% right)

here is my picture example, any help will be much appreciated.

Image

Thank you
Werty
Posts: 66
Joined: 2010-08-06T05:37:36-07:00
Authentication code: 8675308

Re: remove dots from picture before OCR

Post by Werty »

Um, a question first, would we be helping you circumventing some kind of validation "Captcha" like system ?
Windows 7 user
faboloso
Posts: 2
Joined: 2019-08-14T07:23:12-07:00
Authentication code: 1152

Re: remove dots from picture before OCR

Post by faboloso »

No this is not intended for captcha, and not bypassing any captcha system, just reading the information from picture
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: remove dots from picture before OCR

Post by fmw42 »

You can use -connected-components to remove small dots.

Image

Code: Select all

convert img1.png \
\( +clone -threshold 70% -negate -type bilevel \
-define connected-components:area-threshold=5 \
-define connected-components:mean-color=true \
-connected-components 4 \) \
-alpha off -compose copy_opacity -composite \
-compose over -background white -flatten \
img1_result.png
Image
Post Reply