How to convert a .txt file to image format ?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aravind Poolla
am 22 Dez. 2020
Kommentiert: Aravind Poolla
am 24 Dez. 2020
Hello
I have a .txt file that contains the values of pixels i think and if you open the file and scoll down 750 lines you also get a x,y values I dont know how to convert the text file into any image format.
You can find the file in the link below.
Thank you in advance.
6 Kommentare
Image Analyst
am 23 Dez. 2020
Again, "Can you attach it here?" Why didn't you? Is it over 5 MB? Make it EASY for us to help you, not hard.
Akzeptierte Antwort
Walter Roberson
am 24 Dez. 2020
fid = fopen('TXT file.txt', 'r');
datacell = textscan(fid, '%f%f%f', 'headerlines', 762);
fclose(fid);
X = datacell{1};
Y = datacell{2};
V = datacell{3};
F = scatteredInterpolant(X, Y, V);
Nx = numel(uniquetol(X));
Ny = numel(uniquetol(Y));
minx = min(X);
maxx = max(X);
miny = min(Y);
maxy = max(Y);
xvec = linspace(minx, maxx, Nx);
yvec = linspace(miny, maxy, Ny);
[XG, YG] = ndgrid(xvec, yvec);
VG = F(XG, YG);
imagesc([minx, maxx], [miny, maxy], VG.');
set(gca,'YDir','normal')
2 Kommentare
Walter Roberson
am 24 Dez. 2020
It would not surprise me if you could simply take the values (V) and reshape() them instead of doing a scatteredInterpolant.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!