Azzera filtri
Azzera filtri

How can I get gif images from the 300 by 300 raw pixels .txt files?

1 visualizzazione (ultimi 30 giorni)
Hi I am trying to make a gif files from the amount of 500 text files. text files are saved like matrices such as
1.023000000000000000e+03 9.000000000000000000e+00 1.300000000000000000e+01
9.420000000000000000e+02 9.270000000000000000e+02 8.600000000000000000e+01
7.620000000000000000e+02 7.680000000000000000e+02 7.590000000000000000e+02
and I want to make only one gif files included 500 txt files.
Also, I want to make scale bar and automatic range (find minimum and maximum value and set that the minimum and maximum during the play.
Please start at opening the text files!

Risposte (1)

KSSV
KSSV il 23 Gen 2018
files = dir('*.txt') ; % get all text files in the folder
N = length(files) ; % total number of files
% gif starts
h = figure;
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'test.gif';
for i = 1:N % loop for each file
% import the file
data = importdata(files(i).name) ;
surf(data) ;
colorbar
drawnow
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if n == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
  4 Commenti
Jungbae Yoon
Jungbae Yoon il 24 Gen 2018
Modificato: Jungbae Yoon il 24 Gen 2018
First of all, I want to set the path for each try because I will save this kinds of data many times in the future
Secondly, I don't want to get 3D image, I need 2D images with contrast depending on the pixel values. Also, I want to get video(like gif)
KSSV
KSSV il 24 Gen 2018
files = dir('*.txt') ;
The above liens reads all test files in the present folder......you need to read about that.

Accedi per commentare.

Categorie

Scopri di più su Display Image in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by