フィルターのクリア

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

1 回表示 (過去 30 日間)
Jungbae Yoon
Jungbae Yoon 2018 年 1 月 23 日
編集済み: Walter Roberson 2018 年 1 月 24 日
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!

回答 (1 件)

KSSV
KSSV 2018 年 1 月 23 日
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 件のコメント
Jungbae Yoon
Jungbae Yoon 2018 年 1 月 24 日
編集済み: Jungbae Yoon 2018 年 1 月 24 日
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 2018 年 1 月 24 日
files = dir('*.txt') ;
The above liens reads all test files in the present folder......you need to read about that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by