making movie file

3 views (last 30 days)
Rishabh Kasliwal
Rishabh Kasliwal on 22 Apr 2011
Hi All,
I am trying to make a movie file from a image stack. I am using the following sample code (given in MATLAB)
***********************************************************
imgstack = uint16(zeros(32,128,1,no_of_frames));
for frame = 1:no_of_frames
[imgstack(:,:,1,frame)] = imread(filename, frame);
end
map = (linspace(0,64,65))'; map = repmat(map,1,3)/64;
mov = immovie(imagestack,map);
movie2avi(mov,filename)
**********************************************
Few frames (in the middle) have increased intensity in one region. So I expect to see something like a light bulb go on and off. But I notice that it is too bright all over. I want to scale the frames such that max intensity pixel represents 1.0 in colormap and min intensity pixel represent zero (over all frames). In other words the same 'map' is applied universally to all pixels in all frames. How can I do that in the movie? One idea I had is to apply different maps to diff frames, but I dont know how to implement it.
please help
thanks
rishabh

Answers (1)

Walter Roberson
Walter Roberson on 22 Apr 2011
Without answering your question, here are some efficiency hints:
imgstack = zeros(32,128,1,no_of_frames, 'uint16');
map = ndgrid(0:1/64:1,[0 0 0]);
Specifying a frame number to imread() in the way you have is supported only for .CUR and .GIF files. If you are using .GIF files (but not .CUR files) then you could probably gain a fair bit of efficiency by reading all of the frames in a single call, by specifying 1:nframes as the index. .CUR files only support reading one frame at a time. The only other file type that supports reading frames is TIFF files, for which you must use
imread(filename, 'Index', frame)
and a vector of frames is not permitted for TIFF.

Categories

Find more on Display Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!