Pixel values to Image

4 次查看(过去 30 天)
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