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 ....
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!