How to read a .txt file and convert to an image in MATLAB?

49 ビュー (過去 30 日間)
PRACHI SHARMA
PRACHI SHARMA 2019 年 6 月 7 日
コメント済み: Walter Roberson 2019 年 6 月 7 日
Hi!
It looked an easy thing to me but no solution is working in loading a .txt file in MATLAB. I cannot understand why?. The .txt file consists of depth values from kinect camera and separated by a space.
I have tried all the functions in MATLAB for the same but everytime I get a blank variable in which I am trying to load the .txt file.
The .txt file has been attached here. It would be great if somebody who knows this can help me out here.
Thanks in advance!

回答 (3 件)

Walter Roberson
Walter Roberson 2019 年 6 月 7 日
USER111 = load('USER-1-1-1.txt');
imagesc(USER111)
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 6 月 7 日
If you try working with the floating point values up to 2047, it is easy to get into situations where MATLAB does not treat your data the way you think it should be treated. You might want to convert it:
img = mat2gray(USER111); %will return values in the range 0 to 1

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


KSSV
KSSV 2019 年 6 月 7 日
A = load('USER-1-1-1.txt') ;
imagesc(A)

Prasanth Sikakollu
Prasanth Sikakollu 2019 年 6 月 7 日
Try using load() function and convert it to scaled image using imagesc().
Data = load('USER-1-1-1.txt');
imagesc(Data);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by