フィルターのクリア

How to define the spacing between rows in a matrix?

2 ビュー (過去 30 日間)
Basil Imoberdorf
Basil Imoberdorf 2022 年 7 月 22 日
コメント済み: Image Analyst 2022 年 7 月 22 日
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! :)

採用された回答

Image Analyst
Image Analyst 2022 年 7 月 22 日
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 件のコメント
Basil Imoberdorf
Basil Imoberdorf 2022 年 7 月 22 日
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 2022 年 7 月 22 日
You have these options:
format compact
and
format loose
and that's about it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by