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
2017-1-24
If you have "one value per row", how can the information about the X and Y position be obtained?
采纳的回答
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.
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!