# How to create fade gif image OUT OF 6 IMAGES AS GIVEN IN PICTURE?

22 views (last 30 days)
Commented: darova on 3 Nov 2019
Can someone illustrate in MATLAB the given effect with complete code?
Convert gradually from first image to last image(total 6 images);

darova on 30 Oct 2019
Here is an idea:
n = 5 % number of changes between images
for i = 1:n
I = (I1*(i-1) + I2*(n-i))/(n-1); % average image
end
% I = (I1*0 + I2*4)/4
% I = (I1*1 + I2*3)/4
% I = (I1*2 + I2*2)/4
% and so on

Show 1 older comment
darova on 2 Nov 2019
Example
clc,clear
filename = 'gif_animation.gif';
[im,map] = rgb2ind(I1,255);
imwrite(im,map,filename,'DelayTime',0,'Loopcount',inf);
n = 10; % number of changes between images
for i = 1:3 % loop through images
I1 = double(I1);
I2 = double(I2);
for j = 1:n % loop through changes
% operations with double numbers
I = (I1*(n-j) + I2*(j-1))/(n-1); % average image
% convert to uint8 again
I = uint8(I);
[im,map] = rgb2ind(I,255);
imwrite(im,map,filename,'DelayTime',0.1,'WriteMode','Append');
end
end
Result:
Images attached
It works 100%.
Thank you darova. You really did it.
I'll be happy if you reply for later questions of mine!
darova on 3 Nov 2019
• I'll be happy if you reply for later questions of mine!