I'm looking to load image files into Mat lab and save them all to an animated .GIF of a set speed. i have tried loading them in using imread() and mapping them with rgb2ind() then saving with the given imwrite() code from the website appending them to the file, i have errors when trying to use the rgb2ind() saying that i need a uint8 array or a 3Duint8 array when i try various things.
%arg 1 number of inputs
%arg 2 is speed
%arg[] files
function main(varargin)
num = str2num(varargin{1});
speed = str2double(varargin{2});
for i=1:num
a = imread(varargin{i+2});
[A map] = rgb2ind(a,256);
if i==1
imwrite(A,map,'new.gif', 'gif','LoopCount',65535,'DelayTime',speed)
else
imwrite(A,map,'new.gif', 'gif','WriteMode','append','DelayTime',speed)
end
end
a = imread(varargin{i+2});reads a Grayscale image. If this is not the case, please let me know (there is also a chance that your input images are [colored] indexed images, and your are not usingimreadcorrectly). - Rotem