How to display characters in OCR during recognition ?

5 views (last 30 days)
I am doing project in OCR.For recognition part,i want to display of Malayalam characters.Is it possible to display character and then how to convert it.Could anybody help me to solve this ....

Accepted Answer

Walter Roberson
Walter Roberson on 29 May 2013
If you have the Unicode position of a character, and the code position is no greater than U+FFFF, then you can output it to the command window relatively simply.
Malayalam characters are in the range U+0D00 to U+0D7F, so this applies to all Malayalam characters.
Example: U+0D15 which is ക you can output to the command window using
char(hex2dec('0D15'))
You can also create such strings using sprintf()
X = sprintf('#%c#', hex2dec('0D15'))
which would create the string #ക#
And here is another trick for you, for the case where the character number is known in advance (instead of being calaculated):
X = sprintf('#\x0d15#)
However, you cannot display such strings to the command window using fprintf() instead of sprintf()
fprintf('#%c#', hex2dec('0D15')) %will not work as expected
fprintf('#\x0d15#') %will not work either
These would appear to print out ## and if you checked more closely that would be #^Z# where ^Z represents char(26)
To write to a file, you have a couple of choices:
1)
fid = fopen('test.txt','w','ieee-be','UTF-8');
fprintf(fid, '#%c#', hex2dec('0D15'));
fprintf(fid, '#\x0d15#'); %alternate if character is known in advance
fclose(fid);
(You can also use 'ieee-le' instead.)
2)
X = sprintf('#%c#', hex2dec('0D15'));
X = sprintf('#\x0d15#'); %alternate if character is known in advance
fid = fopen('test.txt', 'w');
fwrite(fid, unicode2native(X,'UTF-8'), 'uint8');
fclose(fid);
Option #1 can "look nicer", but Option #2 is more explicit and will match what has to be done when you read the data in.
Then to read the file, you can use
fid = fopen('test.txt', 'r');
T = fread(fid) .'; %gets entire file %note .' here
T = fgetl(fid); %alternate, gets only one line
fclose(fid);
Then
X = native2unicode(T,'UTF-8');
This would give you back the string #ക#

More Answers (0)

Categories

Find more on Text Analytics Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!