Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Puzzles About GIF DelayTime

[TLDR: To create a fast GIF animation using imwrite , 用一个 延迟时间 of 0.02 instead of 0.]
In my 28-Feb-2022 post , I showed some code that created an animated GIF file using a DelayTime of 0.
im = rand(750,750)>0.8;
fork=1:500
t = conv2(im(:,:,k),[2,2,2; 2,1,2; 2,2,2],'相同的');
im(:,:,1,k+1) = (t > 4) & (t < 8);
end
imwrite(~im,'life.gif','DelayTime',0,'LoopCount',1)
作为回应,读者Mikhail评论说,一个人不应该使用 延迟时间 of 0 for the purpose of creating fast GIF animations. He pointed me to an blog post by Ben Phelps called "The Fastest GIF Does Not Exist." (Note: If you visit this site, you may get a security warning in your browser. Apparently, the site's certificate expired a few days ago. Visit at your own risk. I have attempted to contact the author to let them know.)
Many years ago (about 25!), I used to work on image file format support in MATLAB, so I usually start investigating such questions by looking at the specification for the format in question. The relevant spec is GIF89a , and here's the key paragraph:
请注意,如果延迟时间为0,此语言并未准确指定应发生的情况。
One thing I've learned by experience is that the actual behavior of commonly used software applications sometimes varies from the spec, and implementers must pay attention to that. Ben has looked at the publicly available source code for several browsers and other applications and discovered a Delay Time of 0 or 1 (1/100 s) is generally not honored. Instead, for various practical and historical reasons, a very low Delay Time like 0 or 1 is often bumped up arbitrarily to a value of 10 (1/10 s).
因此,不会延迟时间设置为0give you the fastest possible animation! I tested this in Safari, the browser I use on my Mac, and this does appear to be true.
此GIF是使用 延迟时间 of 0:
life (delay time = 0).gif
This one was generated using a 延迟时间 of 0.02 ( imwrite 为此参数使用秒而不是百分之一的秒):
生命(延迟时间= 0.02).gif
Indeed, the second version does animate much more quickly.
一个含义是我们可能需要更改 imwrite documentation, which specifically says to use 延迟时间 0以获取最快的动画:
I actually think it may be time to change the imwrite 界面。也许我们可以给这个参数一个名称,例如 FrameRate , (in frames per second) and document a maximum value of 50 (which corresponds to a 延迟时间 of 0.02 s (or 2 hundredths of a second).
I will make both suggestions to the development team responsible for imwrite .
|
  • print
  • send email

コメント

コメントを残すには、ここMATHWORKSアカウントアカウントアカウントアカウントサインインするする新しい新しい新しい新しい新しいアカウントアカウントアカウントアカウント作成し。。。