Clean up license plates

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
Amused23
Posts: 20
Joined: 2015-09-24T22:48:39-07:00
Authentication code: 1151

Clean up license plates

Post by Amused23 »

Hello,
I am trying to use Tesseract as OCR for license plates. Here are a few examples:
https://www.dropbox.com/s/1ek33a1vrfa8gbv/LP3.JPG?dl=0
https://www.dropbox.com/s/izkz71t61rs84sj/LP4.jpg?dl=0
https://www.dropbox.com/s/6nahcjnw4o4fo0a/LP5.jpg?dl=0

I need to clear up the background and convert it to white while leaving the numbers thick black and bold. How can I accomplish this?
I am using ImageMagick-6.9.3-Q16 on Windows 7.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Clean up license plates

Post by fmw42 »

The first one is very hard because the letters bleed together. The other two can be handled by measuring the approximate "black" color and converting all other colors to white and it to full black. Something like:

Code: Select all

convert LP4.jpg -auto-level -colorspace gray -fuzz 20% -fill white +opaque "gray(80)" -fill black +opaque white LPT4_proc1.png
You will need to play with the fuzz value and the gray value according to the histogram values of your image for the the dark letters.

The other image should be able to be processed similarly.

Alternately, find the fuzz value and the threshold value and do

Code: Select all

convert LP4.jpg -auto-level -fuzz XX% -threshold YY% LPT4_proc2.png
Amused23
Posts: 20
Joined: 2015-09-24T22:48:39-07:00
Authentication code: 1151

Re: Clean up license plates

Post by Amused23 »

The first one with fuzz 30% and gray 40 seems to work the best. Thanks you for your time.
Post Reply