How to define the spacing between rows in a matrix?

6 visualizaciones (últimos 30 días)
Basil Imoberdorf
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! :)

Respuesta aceptada

Image Analyst
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.
  2 comentarios
Basil Imoberdorf
Basil Imoberdorf el 22 de Jul. de 2022
Ok youre right! I tought if i can change the spacing setting in Matlab it would write it down to files too in that manner but ok.
But does that mean there is no way to adjoust the spacing at least in the command window output?
Image Analyst
Image Analyst el 22 de Jul. de 2022
You have these options:
format compact
and
format loose
and that's about it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by