im2frame
将图像转换为影片帧
说明
示例
将图像转换为影片帧
加载狒狒面部的索引图像。
load mandrill
使用关联的颜色图 map
(包含 220 种颜色)显示图像 X
。
figure
image(X)
colormap(map)
axis off
制作一部影片,用于展示减少图像颜色数量的效果。总共将有八个影片帧。预分配一个结构体数组来存储影片帧。
F(8) = struct('cdata',[],'colormap',[]);
以循环方式,使用 imapprox
函数减少索引图像中的颜色数量。使用 im2frame
函数将图像转换为影片帧。第一帧是具有所有 220 种颜色的原始图像。第二帧有 128 种颜色。每个后续帧的颜色数量都依次减半。最后一帧的颜色最少,只有 2 种。
for j = 1:8 q = 2^(9-j); [Y,newmap] = imapprox(X,map,q,'nodither'); F(j) = im2frame(Y,newmap); end
要以每秒三帧的帧速率播放影片两次,请使用 movie(F,2,3)
。
输入参数
输出参数
F
— 影片帧
结构体
影片帧,以包含下列两个字段的结构体形式返回:
cdata
- 存储为uint8
值数组的图像数据。colormap
- 颜色图。对于真彩色 (RGB) 图像,此字段为空。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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)