make a movie from grayscale frames

Hi,
I want to make a movie from grayscale frames after I perform a graphics on them. I put each frame in 4D matrix and I tried to use in "immovie" command but i got this eror message:
"Error using immovie>parse_inputs (line 75)
Truecolor RGB image has to be an M-by-N-by-3-by-K array.
Error in immovie (line 40)
[X,map] = parse_inputs(varargin{:});
Error in main_2 (line 34)
mov=immovie(images,[]);"
How can I make a film from the frames after I painted on them graphics?
Thanks, Itai

1 commentaire

Adam
Adam le 11 Août 2014
Have you tried passing 'grey' as the second argument to immovie? I'm not sure what it does with an empty second argument but judging from the error message it reverts to the single input argument overload which expects an RGB input.

Connectez-vous pour commenter.

Réponses (2)

Joseph Cheng
Joseph Cheng le 11 Août 2014
Just as Adam suggests, I would also agree it looks like you should be passing the grey scale map in the second argument however I do not think just putting 'grey' will work. what you can do is create a map by using
map = colormap(gray(256));%256 as an example.
and then call your the immovie
mov = immovie(images,map);

3 commentaires

itai
itai le 11 Août 2014
Modifié(e) : itai le 11 Août 2014
Hi Joseph,
I try to create the map you suggest me and call the "immmovie" command and this is what I get:
Error using im2uint8 (line 81)
Invalid indexed image: an index was less than 1.
Error in immovie>parse_inputs (line 90)
X = im2uint8(X,'indexed');
Error in immovie (line 40)
[X,map] = parse_inputs(varargin{:});
Error in main_2 (line 35)
mov=immovie(images, map);
what I supposed to do?
Itai
Try something like
map = uint8( 256 * gray(256) );
although I'm sure there's a neater way of achieving that! From the error message it seems to be expecting an unsigned 8-bit colourmap rather than a 0-1 range colourmap such as that gives you.
Hi,
I try to define the map with "uint8" and I'm still getting eror like this:
Error using iptcheckmap (line 31)
Function IMMOVIE expected input number 2, MAP, to be a valid colormap. Valid colormaps must be
nonempty, double, 2-D matrices with 3 columns.
Error in immovie>parse_inputs (line 87)
iptcheckmap(map, mfilename, 'MAP', 2);
Error in immovie (line 40)
[X,map] = parse_inputs(varargin{:});
Error in main_2 (line 35)
mov=immovie(images, map);
I copied the main code for you:
folderIn = 'C:\Users\Administrator\Desktop\documents\bgu\year 2 st 1\image processing\';
folderOut = 'C:\Users\Administrator\Desktop\documents\bgu\year 2 st 1\image processing\';
fileName = '12org_conv.avi' ;
cd( folderOut);
obj = mmreader(fileName);
NumberOfFrames = obj.NumberOfFrames;
N =15 ;
buffer = readMovie(obj,N);
save([folderOut 'buffer.m'],'buffer');
load -mat 'buffer.m';
trackWin = [];
images= [];
for frame = N+1:NumberOfFrames-15
img =double(rgb2gray( read(obj, frame)));
[motionWin thImg ] = MotionDetect3(buffer,img,frame);
trackWin =tracking( trackWin,buffer(:,:,end),img,frame,motionWin );
img = selectedTarget2Display(img,trackWin,frame);
buffer = bufferApdate(buffer,img);
imwrite(uint8(img),[folderOut,'o' sprintf('%04i',frame ),'.jpg']);
imwrite(uint8(thImg),[folderOut,'MD' sprintf('%04i',frame ),'.jpg']);
fprintf([num2str(frame),'\n']);
images(:,:,1,frame-N)=img;
end
map = uint8( 256 * gray(256) );
mov=immovie(images, map);
movie2avi(mov,'mov2');
please help me, Thanks

Connectez-vous pour commenter.

Image Analyst
Image Analyst le 11 Août 2014

0 votes

3 commentaires

Image Analyst
Image Analyst le 11 Août 2014
Attached is a script where I build a movie from a bunch of stored images. If you can save out your images to disk, for example with export_fig(), then this will work, at least it does with the color images in the demo.
Image Analyst
Image Analyst le 11 Août 2014
Are your graphics in color, and you want them to remain in color while the movie is playing? How did you create your 4D stack of color images? Did you use export_fig() to create your color image?
Hi,
The graphics are not in color, the graphics is a white bounding box around targets. I enter each image to a matrix that the first two indices of her are the size of the image, the third index is the color (R,G,B) - I don't know what to put there, the last index represents the number of the frames I put there. this is the row in the code:
images(:,:,1,frame-N)=img;
what you offer me to do?
Thanks

Connectez-vous pour commenter.

Catégories

Question posée :

le 11 Août 2014

Commenté :

le 12 Août 2014

Community Treasure Hunt

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

Start Hunting!

Translated by