Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Jungbae Yoon
Jungbae Yoon el 23 de En. de 2018
Editada: Walter Roberson el 24 de En. de 2018
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!

Respuestas (1)

KSSV
KSSV el 23 de En. de 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 comentarios
Jungbae Yoon
Jungbae Yoon el 24 de En. de 2018
Editada: Jungbae Yoon el 24 de En. de 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 el 24 de En. de 2018
files = dir('*.txt') ;
The above liens reads all test files in the present folder......you need to read about that.

Iniciar sesión para comentar.

Categorías

Más información sobre Display Image en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by