0

say I have these boxes, some of which are black and some white.

enter image description here

The image shows a U shape drawn with the black boxes. Now say I have a matrix of 1s and 0s (it can be a huge matrix) like this:

111111111111111111
111111111111111111
111111111111111111
111111111101111111
111111111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111100000011111111
111111111111111111

which shows zeros forming roughly the shape shown in the image. The image and the matrix are just examples. The image is a screen shot of a software where we should draw patterns, which would then need to be located in given matrices (inside simple text files).

What I'm looking for is a guidance on how to get started on this, cuz I have never programmed anything related to pattern recognitions, which this problem clearly seems to be related to. This is all that I have to do, a pattern given, to be matched with matrix of 0s and 1s. I dont think I can write it on my own in a few days, I'm writing code in c# vs 2013, so hoping I can find some libraries that would let me achieve this with minimal dependencies. Thanks

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
user734028
  • 1,021
  • 1
  • 9
  • 21

2 Answers2

0

I think you need to provide a bit more information on what exactly you're looking for. Are the shapes all letters or arbitrary shapes?

Whatever you're looking for I'd start with emguCV. It's a pretty comprehensive library that isn't too difficult to use.

EmguCV has a lot of OCR (optical character recognition) functions which should be able to pick out letters pretty well.

I don't have as much experience using it for arbitrary shape detection but I think SURF detection, something which emguCV also does, might be a good way to go. It attempts to match a given image with features in another image.

OnABauer
  • 609
  • 4
  • 18
  • the shapes to be drawn and found wont be alphabets, they are just going to be bunch of lines, whatever the user wants to draw in that software. These drawn images then will be translated to 1s and 0s, and which would be matched against a given file of 1s and 0s (the one i drew with 01 matrix). So in the end I think its like one little matrix, being matched against another bigger matrix, and I will have to show where in the bigger matrix, the little matrix is found (not exact matches but whatever the match % is) – user734028 Jul 23 '14 at 10:32
  • I think looking into surf detection may be the way to go. It's usually used for more complex matching than you need, so it might be overkill. I haven't used it much so I'm not sure if it's the best choice. I'd certainly look into it though. As I said emguCV does it pretty well. – OnABauer Jul 23 '14 at 10:39
0

People never draw at the exact same place and scale as your stored data. The things you want are often done with neural networks (its also in aforge). But it might be hard to A understand it and B use it in your code.

So maybe you could try it like this, get the first position, then record the delta position. Try to find long lines, and their next direction; store the general direction changes. above sample would be "down right up", you might also store some length info.

Then there is some math to check how much different sets are, for example string comparisons distance of strings (like in php the levenshtein function); cant think of a levenshtein func in c# dough i dont think c# is that rich with string functions but once you see that i'm sure you can derive something for C#.

user613326
  • 2,140
  • 9
  • 34
  • 63