set the quality of GIF

36 ビュー (過去 30 日間)
高祥 袁
高祥 袁 2021 年 11 月 21 日
コメント済み: 高祥 袁 2021 年 11 月 22 日
x = 0:0.1:10;
y = sin(x);
fig = figure;
lines = animatedline('Color', 'red');
xlim([0 10]); ylim([-1 1]);
frames(100) = struct('cdata', [], 'colormap', []);
filename = 'filename.gif';
for i = 1:100
addpoints(lines, x(i), y(i));
drawnow;
frames(i) = getframe(fig);
[A, map] = rgb2ind(frame2im(frames(i)), 256);
if i == 1
imwrite(A, map, filename, 'gif', 'DelayTime', 1/30)
else
imwrite(A, map, filename, 'gif', 'DelayTime', 1/30, 'WriteMode', 'append');
end
end
How to change the quality of this GIF. Since the capacity is large, I want to reduce the capacity.

採用された回答

DGM
DGM 2021 年 11 月 21 日
GIF has no "quality" parameter. For the most part, you have three choices:
  1. Make the geometry smaller.
  2. Make the color table shorter.
  3. Use frame optimization.
Options 1 and 2 should be pretty obvious. Either use imresize() or specify a shorter CT when calling rgb2ind().
Option 3 isn't really practical within the scope of MATLAB and imwrite(). Write the image and use some external tool (ImageMagick, GIMP, etc) to optimize it.
  1 件のコメント
高祥 袁
高祥 袁 2021 年 11 月 22 日
thank you, I'll try those ways.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by