0

I have matrix 7x7 which consist of 1 and 0 only. How I can detect some letter from this matrix? For example:

0000000
0100010
0100010
0111110
0100010
0100010
0000000

This must be converted as H character. Thank you.

maccettura
  • 10,514
  • 3
  • 28
  • 35
  • 1
    @Adriani6 Remove all the zeros and the 1's are shaped like an `H` – Rufus L Sep 19 '18 at 15:57
  • 5
    Conversion of a bitmap representation of text into text strings is called OCR (Optical Character Recognition). Much of the complexity of OCR is in determining bounding boxes for individual characters, but you already have one letter separated out. Several approaches exist for detecting which letter it is, but a neural network is a very common one. – Ben Voigt Sep 19 '18 at 15:57
  • @Rufus good spot. Didnt see it when I looked at first. – Adrian Sep 19 '18 at 15:58
  • How is this matrix stored? Please show a small sample of code that you're using here. Also, how is the input being received? Are the characters always in the exact same format, or might you get an `H` with slightly shorter legs or narrower body, or lower-case `h`? – Rufus L Sep 19 '18 at 15:59
  • You can create 26 arrays and then compare the given array against all 26 to find character. – jdweng Sep 19 '18 at 16:02
  • much of the complexity of OCR is paying for the OCR software...you don't want to do this from scratch...also recommend if you create an image that it should have the 1's as just a line and the 0's as a blank in your image...otherwise if you have specific exact definitions of what the matrices will look like...thats great and you wont need OCR at all – Ctznkane525 Sep 19 '18 at 16:03

2 Answers2

3

You have to define a "matrix/letter dictionnary". For example, the string 0000000010001001000100111110010001001000100000000 (your matrix put on one line) corresponds to H.

Then, you can search this matrix string in your dictionnary and return the letter it corresponds to.

greyxit
  • 693
  • 3
  • 13
1

Are you trying to accomplish some form of OCR or Image Recognition? A non-scalable solution, since you mentioned a 7x7 matrix, and there are finite characters, would be to code in all possible values you want to capture and perform a comparison against your input.

An easy way to accomplish the above is to transform the 7x7 matrix into a byte array of length 47 (which would be hashable) and store those values in a Map which would relate the byte array to a character.

If however, your input is varied in size, then you may want to either convert the input into the 7x7 example, or look into OCR libraries that handle this better.

Sunny Patel
  • 7,830
  • 2
  • 31
  • 46