How to define the spacing between rows in a matrix?

6 views (last 30 days)
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! :)

Accepted Answer

Image Analyst
Image Analyst on 22 Jul 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 Comments
Basil Imoberdorf
Basil Imoberdorf on 22 Jul 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 on 22 Jul 2022
You have these options:
format compact
and
format loose
and that's about it.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!