How to recognize ASCII image

Hi, I wasn't sure what to put this under, so I hope I've put it in the right one, anyway, I have few ascii image with numbers from 0 to 999, how to recognize which numbers on this image?

Can anyone help me and provide some links where I can read about it?
I thought ASCII was the 256 character set, where did you suddenly get 1000 numbers from?
There is no 1000 numbers, a have few ASCII graphic with different numbers from 0 to 999, like this one:

1
2
3
4
5
6
7
8
9

#######  #####  ####### 
#    #  #     # #       
    #   #     # #       
   #     ###### ######  
  #           #       # 
  #     #     # #     # 
  #      #####   ##### 


I need to open this file, and recognize which number is it.
Last edited on
I got each digit into a separate string for you:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	string Digit1;
	string Digit2;
	string Digit3;
	ifstream ASCII ("Input.txt");
	ASCII.ignore(26, '\n');
	for(unsigned long i = 0; i < 7; ++i)
	{
		for(unsigned long j = 0; j < 7; ++j)
		{
			Digit1 += (char)ASCII.get();
		}
		ASCII.ignore();
		for(unsigned long j = 0; j < 7; ++j)
		{
			Digit2 += (char)ASCII.get();
		}
		ASCII.ignore();
		for(unsigned long j = 0; j < 7; ++j)
		{
			Digit3 += (char)ASCII.get();
		}
		ASCII.ignore(3, '\n');
		Digit1 += '\n';
		Digit2 += '\n';
		Digit3 += '\n';
	}
	cout << Digit1 << Digit2 << Digit3;
	while(true);
}

Now you just need to compare to existing strings to see if the digits match and then make a number out of it ;)
Those 3 for loops, shouldn't they increase the starting j? eg 0 to 7, 8 to 14, 15 to 21?
Why do they need to? They each just need to run 7 times...I don't see why they would need to do anything different.
Last edited on
Ah yes, sorry I misunderstood the code; I thought you first grabbed the first number, then the second (starting again from the top), and lastly the third (so, column by column) instead of getting all three in one time.
and then make a number out of it ;)

can you explain me how to do this?
Well, once you can recognize each digit from comparing them to some constant string versions of the digits, you just need to make the number by multiplying each digit by it's place value and adding them all up. Assume, in this example, that Dig1, Dig2, and Dig3 are integers that contain the correct digits:
int Num = 100 * Dig1 + 10 * Dig2 + Dig3;
Thus, 100 * 7 + 10 * 9 + 5 = 700 + 90 + 5 = 795
Last edited on
Topic archived. No new replies allowed.