Creating a grayscale image from ascii file
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
Could anyone please help me how to create a grayscale image (map) from an ascii file (the file contains three columns: X coord, Y coord and intensity value). So the result of grayscale image will have a georeference coord and the grayscale represents the intensity value. Thank you in advance.
Henz.
I attached the small piece of the file as well from the total 300mb. The grid size is 5 cm and I was thinking to re-gridding with 10 cm or 15 cm of grid size, so the processing time would be not too long. But I don't know how to do that? I really appreciate your help. Thank you.
6 commentaires
Stephen23
le 16 Sep 2018
@hendra kurnia febriawan: are the data scattered or gridded?:
It would probably help if you uploaded the data file by clicking the paperclip button.
hendra kurnia febriawan
le 16 Sep 2018
Modifié(e) : Walter Roberson
le 16 Sep 2018
Réponses (1)
Walter Roberson
le 16 Sep 2018
M = dlmread('file.txt',',');
x = M(:,1);
y = M(:,2);
z = M(:,3);
ux = uniquetol(x);
uy = uniquetol(y);
Z = reshape(z, length(ux), length(uy));
You might need
Z = reshape(z, length(uy), length(ux)) .';
3 commentaires
Stephen23
le 16 Sep 2018
Modifié(e) : Stephen23
le 16 Sep 2018
@hendra kurnia febriawan: some of the values are missing. You can check the sizes yourself:
- ux has size 429x1
- uy has size 1253x1
Now lets calculate how many Z values that would give:
>> 429*1253
ans = 537537
Does M have 537537 rows? No. Actually you have 493606 data values for each of X, Y, and Z. There is no way to reshape a 493606 element vector into a 537537 element matrix. I suspect that you will have to resample/interpolate your data, to get the gridded data that you require. I would love to help you, but your sample file simply repeats the same X and Y values like this (I copied the data verbatim):
4.063e+05,6.474e+06,75.828
4.063e+05,6.474e+06,75.982
4.063e+05,6.474e+06,75.443
4.063e+05,6.474e+06,75.029
4.063e+05,6.474e+06,74.431
4.063e+05,6.474e+06,74.651
4.063e+05,6.474e+06,74.873
4.063e+05,6.474e+06,76.198
...
and I doubt that that represents the real data values (are they really only stored to four/five significant figures?). Please:
- create a file suitable for uploading,
- check the file has useful values (not just 4 sigfig),
- edit your question,
- upload the file by clicking the paperclip button.
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!