im2frame
Convert image to movie frame
Description
Examples
Convert Images to Movie Frames
Load an indexed image of a mandrill's face.
load mandrill
Display the image X
using its associated colormap, map
, which has 220 colors.
figure
image(X)
colormap(map)
axis off
Make a movie that shows the effect of reducing the number of colors of the image. There will be eight movie frames in total. Preallocate an array of structures to store the movie frames.
F(8) = struct('cdata',[],'colormap',[]);
In a loop, reduce the number of colors in the indexed image by using the imapprox
function. Use the im2frame
function to convert the images into frames of a movie. The first frame is the original image with all 220 colors. The second frame has 128 colors. Each successive frame has half the number of colors. The last frame has the minimum number of colors, 2.
for j = 1:8 q = 2^(9-j); [Y,newmap] = imapprox(X,map,q,'nodither'); F(j) = im2frame(Y,newmap); end
To play the movie twice with a frame rate of three frames per second, use movie(F,2,3)
.
Input Arguments
RGB
— Truecolor image
m-by-n-by-3 numeric array
Truecolor image, specified as an
m-by-n-by-3 numeric array. If you
specify an image of data type double
, then values must be
in the range [0, 1].
Data Types: double
| uint8
X
— Indexed image
m-by-n matrix of integers
Indexed image, specified as an m-by-n matrix of integers.
Data Types: double
| uint8
map
— Colormap
c-by-3 numeric matrix
Colormap associated with indexed image X
, specified
as a c-by-3 numeric matrix with values in the range [0,
1]. Each row of map
is a three-element RGB triplet that
specifies the red, green, and blue components of a single color of the
colormap.
Data Types: double
Output Arguments
F
— Movie frame
structure
Movie frame, returned as a structure with two fields:
cdata
— The image data stored as an array ofuint8
values.colormap
— The colormap. For truecolor (RGB) images, this field is empty.
Version History
Introduced before R2006a
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)