thermostat picture make black and white

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
jokken
Posts: 4
Joined: 2015-05-07T10:32:22-07:00
Authentication code: 6789

thermostat picture make black and white

Post by jokken »

hi, in the end I hope to be able to OCR the text out of this picture or an edited version of this picture.
the top left 73 is the most important the other 73 and the time 9:56 are nice to haves..

Image

I assume I first want to make this picture totally either black or white (no grayscale). White background (no green) with the black text (or greenish black text).
and then make the greenish black part of the text real black
and then make the text have some real hard defined borders

I've been playing with convert.exe and
threshold
black-threshold
white-threshold

and I am totally getting the opposite result as I expect. Also I am a bit confused at the huge number of option availables. im in over my head. I am a novice admittedly.

any help would be appreciated. these are some really cool tools...

thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: thermostat picture make black and white

Post by fmw42 »

try using -lat WxH+Offset as follows. adjust the arguments as desired.

Code: Select all

convert try.jpg -channel g -separate +channel -auto-level -negate -lat 25x25+5% result.gif 
jokken
Posts: 4
Joined: 2015-05-07T10:32:22-07:00
Authentication code: 6789

Re: thermostat picture make black and white

Post by jokken »

wow nice that works well thanks!
it gets me way further then i hoped. now for a OCR tool that can pull that text out. the one Ive been trying Tesseract-OCR does not seem to get anything (ever)
jokken
Posts: 4
Joined: 2015-05-07T10:32:22-07:00
Authentication code: 6789

Re: thermostat picture make black and white

Post by jokken »

i used -negate again and got it white with black text.


is there a way I can make the numbers edges more defined (smoother white/black borders) and get rid of the black speckles all around?

Image

i know im asking alot

thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: thermostat picture make black and white

Post by fmw42 »

First thing is pay with the -lat size and offset percent. Get it as good as you can. Then you can try using -morphology smooth Octagon:X where X is an integer that controls the size of the spots to remove. But it will likely affect your numbers and letters. See http://www.imagemagick.org/Usage/morphology/#smooth

Note you may get different results if your letters are white on black vs letters black on white. So try both ways.
jokken
Posts: 4
Joined: 2015-05-07T10:32:22-07:00
Authentication code: 6789

Re: thermostat picture make black and white

Post by jokken »

thanks fwm42 im getting a good deal better images with your suggestions. thanks
Post Reply