How to define the spacing between rows in a matrix?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Basil Imoberdorf
el 22 de Jul. de 2022
Comentada: Image Analyst
el 22 de Jul. de 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 comentarios
Respuesta aceptada
Image Analyst
el 22 de Jul. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!