How to display characters in OCR during recognition ?

2 次查看(过去 30 天)
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 ....

采纳的回答

Walter Roberson
Walter Roberson 2013-5-29
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 #ക#

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by