From: Chen yuan on 30 Jun 2010 07:42 "Mo " <m007mobond(a)hotmail.com> wrote in message <htgt2q$psf$1(a)fred.mathworks.com>... > hi everyone, > > i was working on a project where i want to take some images and make video out of them. I have 5 images and i want to combine them into a video '.avi' file...i've tried the following code but it brings up an error saying "Indexed movie frame must have a non-empty colormap" at the "im2frame" part where the images are converted into frames so they van be added to the aviobject created earlier in the begining of the code any sugestions: > > %%%%%%%%%%Begining of code%%%%%%%%%%%%% > clear all; clc > > %dirctory of the saved jpg images > jpgFiles = dir('*.jpg'); > > %create video object file > aviobj = avifile('Reconstucted_Image_video.avi'); %creatting a movie object and save it > > for i=1:1:5%length(bmpFiles) %number of images to be read > % filename = bmpFiles(i).name; > % [a, map] = imread(filename); > [a, map] = imread(strcat('Reconstucted_Image',strcat(int2str(i),'.jpg')));%reading %the 5 images named Reconstucted_Image1.jpg, Reconstucted_Image2.jpg, Reconstucted_Image3.jpg,Reconstucted_Image4.jpg,Reconstucted_Image5.jpg > %strcat: string concatinate to concatinate the image > %number with the '.bmp' > %file, int2str: convert from integer to string, a map > %is required since this type of image is a 2D logical > %image, therfore it is required to provide it's map > %with it so it can be converted into frames to be > %able to be attached to the avi file to be played. > > a = uint8(a);%convert the images into unit8 type > > M = im2frame(a, map);%convert the images into frames with the associated map since it's not a 3D matrix > aviobj = addframe(aviobj,M);%add the frames to the avi object created previously > fprintf('adding frame = %i\n', i); > end > > %save the video file as a '.avi' file > % avi = avifile('Threshold_frame_video.avi'); > > %close the avi file > disp('Closing movie file...') > aviobj = close(aviobj); > > % avi = close(avi); > > %play the movie > disp('Playing movie file...') > implay('Threshold_frame_video.avi'); > %%%%%%%%%%End of code%%%%%%%%%%%%%%% > > thanks in advance, try this code before addframe function: aviobj.colormap=gray; % add the colormap;
|
Pages: 1 Prev: Eye Tracking Next: GUI and external functions + popupmenu value problem |