Pixel values to Image

조회 수: 4 (최근 30일)
Nils Boden
Nils Boden 2017년 1월 24일
편집: Benjamin Kraus 2017년 1월 24일
Hey,
Hopefully someone can help me with my problem, I cant seem to find a proper solution. I have a very big .txt file with depth values, one value per row. I want to create an image using these depth values, the grid has to be 170000x170000.
The color of each Pixel has to be dependend on the Value, so that I get a depth-map visualitsation from my Values.
I hope I described the problem good enough, thanks for any help.
  댓글 수: 2
Jan
Jan 2017년 1월 24일
If you have "one value per row", how can the information about the X and Y position be obtained?
Nils Boden
Nils Boden 2017년 1월 24일
Because I have the resolution of the final image, from which the data comes. Its 170.000x170.000, so my .txt has 28.900.000.000 rows.

댓글을 달려면 로그인하십시오.

채택된 답변

Benjamin Kraus
Benjamin Kraus 2017년 1월 24일
편집: Benjamin Kraus 2017년 1월 24일
You need to read in your text file using one of the methods described on this doc page: Ways to Import Text Files. If your data is just a single column, most of those functions should work.
Once you've imported your data, you need to reshape the data to your square matrix.
Then you can call something like imagesc to make it into an image. You may want to adjust the colormap afterward.
Something like this:
vals = dlmread('bigdata.txt');
vals = reshape(vals, 170000, 170000);
imagesc(vals)
Note that MATLAB is column-major, so the first row of vals will be the first 170000, the second row will be the second 170000, etc. You can transpose the matrix if this isn't what you wanted by adding a single quote following the call to reshape:
vals = dlmread('bigdata.txt');
vals = reshape(vals, 170000, 170000)';
imagesc(vals)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by