How to create an image from .txt file ?
Show older comments
I have some .txt files containing 3 columns of number (x,y,z). z is the luminosity of each point identified by the x,y coordinates. I should find a way to produce an image file (the format is not important, it may be a .jpg for example) in which the luminosity of each point identified by the first 2 columns of the .txt file (x and y coordinates) vary depending on the third column. How can I concert the coordinates and luminosity into an image? Thanks!
5 Comments
Walter Roberson
on 27 Apr 2017
Have you ever considered the benefits of describing the relationship between the inputs and the desired image?
Lamberto
on 27 Apr 2017
Image Analyst
on 27 Apr 2017
Not sure what your edit was. Was there something in my solution below that didn't work?
Walter Roberson
on 28 Apr 2017
Luminosity? Luma? http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
Are the coordinates spaced on a grid? Is data given for every point on the grid? Are the coordinates positive integers? Should it be assumed that any unoccupied location is black, or should it be assumed that each given location is a point source and each unoccupied location should be interpolated according to inverse square of the distance from the closest point in each direction?
Lamberto
on 9 May 2017
Accepted Answer
More Answers (1)
Walter Roberson
on 9 May 2017
imgdata = load('Case06_RAW_100_01.txt'); %x y luminosity
luminosity = reshape( imgdata(:,3), 696, [] ) .';
However, we are now stuck in producing an image. luminosity is the total amount of energy emitted by an object or region, over all wavelengths, and gives no information about how we should convert into color. Portions might be emitting mostly in the microwave ranges, portions might have a dual peak in gamma radiation and ultraviolet, and a dull blue object might have the same luminosity as a bright red object since blue is higher energy.
If you want to get an idea of how the luminosities are distributed to verify whether the data has been read into the correct positions, then you can
imshow(luminosity, [])
3 Comments
Lamberto
on 13 May 2017
Walter Roberson
on 13 May 2017
imagesc(luminosity);
cmap = prism(64); %choose colormap and size
colormap(cmap); %activate it
Lamberto
on 16 May 2017
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!