Effacer les filtres
Effacer les filtres

How do i create and image from alpha-numeric characters?

8 vues (au cours des 30 derniers jours)
jeremy appling
jeremy appling le 21 Nov 2016
Commenté : DGM le 13 Mai 2024
I have a library say the alphabet and numbers, I have and images say Marilyn Monroe(grayscale) now i want to make the sales man problem and the nearest neighbor assign the best possible pixel representation to convert the image into this library of alpha-numeric pixels.
  3 commentaires
Stephen23
Stephen23 le 12 Mai 2024

Backup of the link Walter Roberson posted above:

https://web.archive.org/web/20160121151336/http://picascii.com/

DGM
DGM le 13 Mai 2024
It says it outputs text/html, but the sample outputs appear to be images of text instead. The converter doesn't appear to actually work anymore, but I'm going to assume that it's text output like the FEX submissions.
I suppose I interpreted the goals differently, but OP never did clarify.

Connectez-vous pour commenter.

Réponses (2)

DGM
DGM le 11 Mai 2024
Well it's Saturday, so I guess it's dead question time.
I don't know how OP proposed to treat the mapping process as a travelling salesman problem. Perhaps that's to say that the character form and shape should be used to best preserve features (e.g. edges) which both are narrower than a single character and span multiple characters. I don't know what the offered link used to be either. Either way, I'm just going to ignore the suggestion and do a simple grayscale mapping.
So you need a set of character images sorted by their average value. MIMT has a tool (impatsort()) to do that. It's primarily intended to work on pattern files, but it can also process the font files used by textim().
To apply the character images, one normally would use MIMT impatmap(), but this is a bit of a complication. Since we want the individual characters to be preserved in whole, we need to work around the intended usage of impatmap(). That's easy enough to do with some downsampling.
% the source image file (grayscale, uint8)
inpict = imread('lena_gray_256.png'); % not part of MATLAB
% parameters
columns = 300; % characters per row
fontfile = 'TOOLBOX/fonts/everex-me.mat'; % MIMT textim() font file
charsize = [8 5]; % this should match the specified font file
% make image size integer-divisible by charsize
szi = imsize(inpict,2); % MIMT-only
ari = szi(1)/szi(2);
szo(2) = charsize(2)*columns;
szo(1) = floor(szo(2)*ari/charsize(1))*charsize(1);
outpict = imresize(inpict,[NaN szo(2)]);
outpict = outpict(1:szo(1),:,:);
% downsample
outpict = blockify(outpict,charsize); % MIMT-only
% generate pattern set ordered by graylevel
[G ugl] = impatsort(fontfile,'addinv',true); % MIMT-only
% apply pattern mapping to the downsampled image
outpict = impatmap(outpict,G,ugl,'nlevels',numel(ugl),'pickrandom',true); % MIMT-only
imshow(outpict,'border','tight')
Click on the image and open it full-scale to see the detail. This uses the full CP437 character set and both polarities.
While there are arguably plenty of other ways to do the mapping, using impatsort() to collect and sort the candidate pattern images is probably the primary convenience here.

Image Analyst
Image Analyst le 12 Mai 2024

Catégories

En savoir plus sur Image Processing and Computer Vision dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by