Re: Advice for OCR solution (or alternative)
From: Andrew Parker (aparker_at_stanford.edu)
Date: 08/02/04
- Next message: Larry Barowski: "Re: can I obtain information about the monitor by programming in Java?"
- Previous message: David: "How do I reference a Local Home interface?"
- Next in thread: Eric Sosman: "Re: Advice for OCR solution (or alternative)"
- Reply: Eric Sosman: "Re: Advice for OCR solution (or alternative)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 2 Aug 2004 09:36:00 -0700
I guess I'll just keep replying to the group so everyone has the benefit of
seeing this solution, though it looks like just a conversation between Roedy
and me here.
My font is not fixed width (which would have made life much easier).
However, it is only one font and one size.
One thing that's nice is that none of the letters in the font extend into
each other. Although it is not a fixed width font, there is assurance with
this character set that there will be at least 1 pixels' width of space
between each character (sometimes more than one pixels width). So I can
just look for vertical white lines of bits to find letter separations.
One note regarding your letter separation scheme. it might fail on lower
case "j" and "i" where not all of the letter is entirely connected.
I agree a that hashing a predefined character set of cut up images is
definitely the best way to go.
I would love to find a canned solution, or something close to it, but my
search thus far has been stale. Given this new information regarding the
font, if you have any suggestions of open source projects that may have
already tackled this problem, I'd be quite grateful.
Thanks,
Andrew
My solution does not need to be multiplatform.
"Roedy Green" <look-on@mindprod.com.invalid> wrote in message
news:mislg0ttlb85u9dn4csgcmtg06s483fqkl@4ax.com...
> On Fri, 30 Jul 2004 16:05:43 -0700, "Andrew Parker"
> <aparker@stanford.edu> wrote or quoted :
>
> >Thanks, loading a hashtable with all the possible characters and then
> >hashing each isolated character in the image sounds like an intelligent
> >idea. However, I'm short on graphics programming experience. Do you
have
> >any links to resources for manipulating images on such a small
> >pixel-by-pixel scale? Are there library classes specifically tailored to
> >this kind of work?
>
> Before you launch into this, I suggest you look a little longer for a
> canned solution. Does it need to be multiplatform?
>
> You first want a simple two-colour screenscrape in white and black.
>
> Are there any simplifications?
>
> 1. only one font
>
> 2. only one size.
>
> 3. fixed vertical distance between lines.
>
>
> Let's start with something simple, a program that can identify a
> single 5-letter word painted in black and white. The word has been
> isolated into an image surrounded by some whitespace. Your first job
> is to break it into separate letters.
>
> Here is a klutzy but fairly easy to understand algorithm. You want to
> create an image in six colours. Each letter of the word is painted in
> a different shade of red. You scan to find the first pixel of the
> first letter. You paint it red. Then you look at the pixels above,
> below, left and right of that one that are black, and paint them red
> too. Repeat recursively until you find no more black pixels. Now
> repeat looking for the first black pixel which will be the first pixel
> of the second letter. Paint its neighbours red2. Keep going.
>
> Now isolate the first character, chopping off the white space around
> it. Repaint it in black and white. You can think of it is a binary
> string of bits. Compute a hashcode on it. (In practice, you would do
> this all in one pass and avoid any red paint).
>
> You have precomputed a set of hashcodes on all the possible letters of
> the alphabet, pruned. Lets say both b and R have the same hashcode as
> the letter you are trying to identify. This means your letter has to
> be either b or R. Nothing else is possible. You then compare them bit
> by bit to see which of the two it really is. In practice you may
> never have to do this. You might even try fudging your hashCode
> algorithm until you don't. A HashMap will do this for you with equals
> defined as bit wise image compare.
>
>
> Here is a hashCode algorithm you might use -- rather klutzy, more to
> give you the basic idea.
>
> hashCode = xor sum of x*149 ^ y* 257 for each black bit.
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
- Next message: Larry Barowski: "Re: can I obtain information about the monitor by programming in Java?"
- Previous message: David: "How do I reference a Local Home interface?"
- Next in thread: Eric Sosman: "Re: Advice for OCR solution (or alternative)"
- Reply: Eric Sosman: "Re: Advice for OCR solution (or alternative)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|