필터 지우기
필터 지우기

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 CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by