We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › pattern recognition and ORC
Page Index Toggle Pages: 1
pattern recognition and ORC (Read 2486 times)
pattern recognition and ORC
Jun 13th, 2007, 10:11am
 
are there any libraries or contributions in processing that helps me recognizing text, numbers and patterns in images?
thanks!
Re: pattern recognition and ORC
Reply #1 - Jun 13th, 2007, 8:44pm
 
Nope.

You need to search on the web for "Optical Character Recognition". The results can be quite disappointing though. When was the last time you bought a web cam that can convert some text on paper into a Word document The problem is that even on an 360x440 image you've got to wade through 158,400 pixels to see if there's anything sensible there.

Also look up filters - you'll need them.

Your best best if I haven't put you off is to look on the net for Java projects that do what you want. You can still import them into Processing, or failing that ask the board about how to integrate a particular Java library in Processing.

Here's a start:

Somebody's OCR project
Re: pattern recognition and ORC
Reply #2 - Jun 14th, 2007, 12:58am
 
Thanks for your help(nice pointer)!  In my case I acutally only need to do OCR on static high resolution images.  I have filtered the image so that it is black and white and contains only letters of interest.   My only constraint is that it has to be opensource and java based. can't seem to find a solution so far... but I'll keep looking.
Re: pattern recognition and ORC
Reply #3 - Jun 16th, 2007, 11:27pm
 
Sounds like what you might need is to roll your own neural network.  You're kind of in luck - http://www.jooneworld.com/ is the home of Joone, an open source Java NN package.  The downside?  Unless you're somewhat (very?) experienced with using neural networks effectively, you're never going to be able to use this to do what you want.  One of the introductory examples they give with that package is using it to perform handwriting OCR, but I'll warn you, it doesn't really work so well, and that example only handles very low resolution images (I think it's 9x9 or something like that).  But at least in theory, their package can do what you want, it would just take a whole lot of work.

My suggestion is that if you do try to do this, you'll need at least one preprocessing step which picks out each character and makes sure it's oriented correctly.  Beyond this, I really hope that you're dealing primarily with a single font and not with handwriting, because that constrains the types of tough calls your program will need to make.

Then again, if you _are_ just dealing with a single font of a fixed size, you may have better luck storing an image of each pixel, getting each character, and rotating/shifting/scaling it until you get a probable match (which you can tell because most of the pixels will line up).  Still, though, this is a very tough problem, so be prepared for a lot of work ahead.
Re: pattern recognition and ORC
Reply #4 - Jun 17th, 2007, 1:12pm
 
A neural net should only be used on a small amount of data. I'm using one right now for a drawn shape recognition game, and I'm using lots of other methods to recognise drawn shapes (line intersections, average angle of all lines etc.) and falling back on the neural net when everything else fails. Plus I use a series of methods to simplify the line drawn into 15 points (interpolating to average the distance between recorded points and then taking only 15 across the spread).

The problem I had explaining to my boss was that there was never a situation where the neural net was generally unsure about the result. It always was convinced it was this result, even if it was completely wrong.

There are lots of other, much simpler and easier methods you can come up with on your own to recognise shapes. And when all of those fail you can use a Back-Propagation Neural Net to try and get a rough answer. But heuristics (a tree of descisions) is the important thing here.

my $0.02
Re: pattern recognition and ORC
Reply #5 - Jun 18th, 2007, 5:07am
 
thanks folks for all the wonderful pointers.  I have also found a simple javaNN called generation5 to try it out on OCR, it has a simple example of recognizing digits of 5x7 pixels using 35 perceptrons.  I need to try it out on my characters which are more in the 30x30 pixels range.  Is there any reason perceptrons would not work well on higher resolution images?  don't I simply scale it up to 900 perceptrons?  st33d mentioned that nn would not work well on larger sets of data, why?
Re: pattern recognition and ORC
Reply #6 - Jun 18th, 2007, 11:17am
 
Provided you've got a free afternoon to wait for results in training or recognition - go for it.
Re: pattern recognition and ORC
Reply #7 - Jun 18th, 2007, 7:14pm
 
it seems that single layered perceptron will do the job.  It takes very little time to train and recognize!
http://www.generation5.org/content/2004/simple_ocr.asp
Re: pattern recognition and ORC
Reply #8 - Jun 19th, 2007, 11:03am
 
That's a really good link there.

However - That's only for dealing with numbers 0-9 on a small grid. And noisy samples are used as well to refine the training.

The larger the sample set, the higher the margin of error. And you're after the alphabet in 30x30 chunks.

I guess it's possible you could use something like the blob recognition library by v3ga to isolate characters on an image and then offload these to the perceptrons - modifying their scale on the way. Stuff which isn't centered and to scale will throw off results so that would help.

I really can't say whether it would work. But it's certainly worth a try!

Good luck and even if it doesn't work, tell us what happened - it's possible there's a workaround.
Re: pattern recognition and ORC
Reply #9 - Jun 19th, 2007, 10:53pm
 
First, I agree with all of st33d's posts 100% - neural nets are no magic bullet here, but they can help as a fallback if you can't figure the character out using other means.

To understand why higher resolution data is difficult to use with neural networks, consider this: a neural net with M input nodes, N intermediate nodes, and O output nodes has MxN+NxO connection weights to train.  That means you have a whole crapload of parameters to vary, and the more parameters you have to set, the more independent input data you need.  The problem?  Think of polynomial curves - a N-th degree polynomial can exactly fit N+1 data points, though the resulting polynomial will tell you nothing at all about the underlying pattern in the points.   This phenomenon is known as overfitting, and is especially prevalent in neural networks because the number of connections is so huge.

Doubling the resolution of an image multiplies the number of pixels by 4, so quickly pushes up the number of input nodes.  To get anything out of these, you'll likely have to increase the number of hidden nodes, so the number of connections to train increases VERY quickly.  To get meaningful results, this forces you to increase the training set even more dramatically, and if I recall, the total training time increases even faster than any of these values.  So that's why it's not easy to scale - you're dealing with an O(N^p) process where p is some fairly large number.

From what I remember, sometimes Kohonen or RBF nets are well suited to classification tasks, and I think these scale a bit better than your standard feedforward one, so you may give a look there.

Also, if you need to take high-res input, consider filtering it down to a lower, more usable resolution first, perhaps several different times in several different ways.  If your classifier gives the same answer on each different filtering, you can probably be fairly confident that it's correct; if the predicted character differs, this may be an indication that the confidence level is fairly low.

One other thing I would recommend - if you're dealing exclusively with English text, for instance, you might consider recognizing characters in context, for instance if the last three letters were 't,' 'h,' and 'i,' there's a much higher probability that the next character will be 's' than 'a,' given the 4-character probabilities for English text (though if the next letter is 'm,' you might have "thiamine," so the possibility of 'a' has to be kept open...).  You can often make do with a less accurate character recognizer if you employ tricks like that to post-filter your strings, though robust implementations of these types of tricks can be difficult.
Re: pattern recognition and ORC
Reply #10 - Jun 20th, 2007, 9:25pm
 
thank you both for the wonderful explanations.  I will keep you guys posted about my progress on using perceptrons recognizing characters.
ewjordan, you mentioned about the hidden layer in NN, if I use no hidden layer, the NN can still do the classification of the character nicely, can it?  under what situations would I need a hidden layer?  If i can get away with the hidden layer, then I guess the number of connections wouldn't be so large(MxO).
Re: pattern recognition and ORC
Reply #11 - Jun 21st, 2007, 10:51am
 
ewjordan thinks you are using a back propagation neural net, which uses three layers of interconnected perceptrons. He hasn't guessed that you might be using a single layer of perceptrons.

The purpose of using multiple layers is that it can recognise situations a single layer can't.

But what ewjordan was saying about the noise is true. You're taking a tool that tries to deal with a lot of confusing information. But instead of making it easier for that tool to do the job, you are taking the piss out of it.

I'm pretty doubtful it will work (or at least it will appear to work and then you'll find it can only recognise three letters). But I've no hard evidence other than that every time I've tried to teach a neural net more patterns, it gets worse at it's job. So I say go for it. Prove me wrong and add to my research.

I take it you haven't tried if you're still asking questions. Come on then!
Page Index Toggle Pages: 1