How to convert a ASCII character to matrix
Mostrar comentarios más antiguos
I am working on pattern recognition and need to have a dataset containing characters on a white background and size should be 8 by 8 pixels. The dirty and tedious solution is to create a matrix for each character manually like this:
A=[255,255,255,000,000,255,255,255;
255,255,000,255,255,000,255,255;
255,000,255,255,255,255,000,255;
000,255,255,255,255,255,255,000;
000,255,255,255,255,255,255,000;
000,000,000,000,000,000,000,000;
000,255,255,255,255,255,255,000;
000,255,255,255,255,255,255,000];
imshow(A);
it works but it takes ages to create a dataset with 1K-10K images. I tried to do so by using 'insertText' but it did not work properly as desired size of matrix is too small.
Briefly, I would like to use 'char' to create a database of all characters and symbols. How I can write a program to create like the above matrix automatically? Any help is really appreciated.
Respuesta aceptada
Más respuestas (2)
There are datasets around; google 8 x 8 character bitmaps
To extract a matrix from the hex numbers, you can use
% character 'n'
n = dec2bin(hex2dec(['00'; '00'; '1F'; '33'; '33'; '33'; '33'; '00']));
M = 1 - (n - '0');
imshow(M)
Walter Roberson
el 20 de Jul. de 2016
Editada: Walter Roberson
el 20 de Jul. de 2016
0 votos
Download an 8 pixel bitmapped font. Available ones include
... and others.
3 comentarios
david jones
el 25 de Jul. de 2016
Guillaume
el 25 de Jul. de 2016
A truetype font (TTF) does not contain a pixel matrix for characters. It contains instruction on how to draw the characters (in the form of paths).
Fonts (except for some very old formats) are vector graphics, not raster graphics. Therefore you need an intermediary (the OS, matlab's InsertText, etc.) to render the font as a bitmap, taking into accounts the font size you specify.
Walter Roberson
el 25 de Jul. de 2016
Categorías
Más información sobre Object Detection en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!