How to define the spacing between rows in a matrix?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Basil Imoberdorf
le 22 Juil 2022
Commenté : Image Analyst
le 22 Juil 2022
Im coding an algorithm to convert images into a textfile where each pixel corresponds to an ascii character.
It works all fine but the dimensions are distorted because of the given default spacing between the rows. Here is an example:
ascii_img =
56×70 char array
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' ´.,,,´ '
' .~=;<<££<~ '
' ´-=:;<££%¢¢¢£. ´´´´´ '
' ´-=:;<£%¢¢¢§¢¢¢- ´.,,--~~~~~~~=:;:- '
' ´,~:;££%%¢¢¢§§§§¢~-~~-----~~~~-,,,-=:<- '
' .~:;<££%%¢¢§§§§§¢£,.´´´´´´.,,~:-,,,~:<, '
' ´,~:;<£%%¢¢¢§§§¢¢¢¢~ .,-:-,,-=;= '
' ´-=:;<£%%¢¢¢¢¢¢§§§§< ´,-:~,,-=;~ '
' .-=:;<£%%%%%¢§§###§¢ ´,~=-,,~::. '
' ´ .-=:;<<£%%¢§§§§###§¢´ ´.-=-,,-::, '
' ´.,, .-~:;<£%¢¢¢§§§§##§£- ´.~~-,,~::, '
' ´.,,.´ .-=:;<£%%¢¢§§§§§£~.-.,~~-,-~:=, '
' .,,,.´ ´.-=:;<£%%¢¢¢§%:,,-=:~-,,-=:~´ '
' .,.,,´ ´´,~:;<£%%%£:-,,~:;:~,-=:=. '
' -~,~~, ´´.-=:;;:~,,,~=::=::=:=, '
' -=-,=~,´ ´,--,,,~==:==::;<=, '
' ´:~,,~:,,´ ´..,-~======:;<<££= '
' ,;~,,,~:~-,,,.,,,-~~~~~--~~=:;<<<<<<= '
' .<=-,,,,-~====~~~--,,,,-~:;;;:::;;;:- '
' ~<:=-,,,,,,,,,,,--~~=::~-.´,-~~===- '
' ´:<;::==~~===:;::=-,´ ´.´´ '
' ´,-~~~~~-,.. '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' '
' ´ '
' ;;. =~-=-:~~=, '
' =~. =,,-,-.´,. '
' ´ ´ '
The original picture is 560 (y-Axis) by 700 (x-Axis) pixels.
I need the horizontal spacing as the new vertical spacing because i think the horizontal spacing between each character is always equal no matter the char.
This would hopefully fix my dimension problem
If its not clear what i mean here you can see the corresponding option in word:
Thanks in advance for your help! :)
0 commentaires
Réponse acceptée
Image Analyst
le 22 Juil 2022
A text file is just a file. The "aspect ratio" of the "image" produced by the characters depends on how you display it. If you're using Word, you can vary the line spacing, as you've shown, or you can try different font names. But an ASCII values does not have any inherent aspect ratio and the data on the disk are just binary 1's and 0's (as are all computer files) so it all depends on how that disk file is rendered for display. This is not a MATLAB question and there is nothing MATLAB can do to fix your text file so that it displays with the desired aspect ratio in every possible program you might use to read in that text file. If you want to produce an image, like a .PNG file, instead of a text file, like a .txt or .dat file, then you could adjust the spacing more precisely.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB 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!