MATLAB getframe用法
来源:互联网 发布:网站性能优化方案 编辑:程序博客网 时间:2024/06/05 05:14
F =getframe(h,rect) specifies
arectangular area from which to copy the pixmap. rect is
relativeto the lower left corner of the figure or axes h,
in pixelunits. rect is a four-element vector in the form [left
bottomwidth height], where width and height define
thedimensions of the rectangle.
本函数是要从图形对象中截取一块出来。其中h是图像句柄,rect是一个四元素向量,代表[a b c d],其中a表示截取区域到图像左端的像素数,b表示截取区域到图像底端的像素数,c表示截取区域水平像素数,d表示截取区域垂直向像素数。
得到的F是一个结构体(struct),包含两个元素:cdata和colormap,其中cdata是截取区域的数据,是一个三维数组,其中第三维的长度是3,即截取到的是区域中RGB的值。colormap是调色板,这个没啥意思。
例如:
x=0:pi/100:2*pi;
y=sin(x);
plot(x,y)
set(gcf,'color',[1 1 1]) %设置背景色为白色
title('测试图像保存')
F=getframe(gcf); %获取整个窗口内容的图像
F1=getframe;
imwrite(F.cdata,'test1.png')
imwrite(F1.cdata,'test2.png')
getframe获得的是一个架构struct类型的数据,
其中cdata子域的内容才可以用imwrite内容保存,用F.cdata表示
getframe(gcf)即get current figure,获得窗口内图像,包含legend、title以及label。如果不添加gcf,默认为gca(get currentaxis)。
imwrite可以保存jpg、png等格式图像,gif是7.0添加的,但是好像没办法保存为动画,只能保存第一帧。
与在图像界面直接利用复制,或用file>saveas...保存不同的是,imwrite的背景色为窗口实际颜色,默认为灰色(RGB表示为[.7 .7 .7]),若想保留白色背景图,需添加例子中的set gcf color命令。
- MATLAB getframe用法
- MATLAB getframe用法
- MATLAB getframe用法
- MATLAB getframe用法
- getframe matlab
- matlab getframe()
- getframe
- matlab getframe frame2im 存储坐标到图片
- MATLAB中getframe应用函数举例
- Matlab 保存多个图像 getframe、imwrite、sprintf、num2str、doc
- MATLAB 冒号用法大全
- matlab命令用法
- matlab中plot用法
- matlab fspecial 用法解释
- MATLAB filter 函数用法
- matlab cell数据用法
- matlab中nargin用法
- Matlab norm 用法小记
- 临界资源、临界区、信号量、P,V操作
- 小感想 | 面向对象和非面向对象程序的区别是什么?
- 数据库学习笔记1
- Python之查单词问题
- npm装bower
- MATLAB getframe用法
- xiazzai
- js导出excel表格
- 彻底理解ThreadLocal(转载)
- JavaScript-DOM
- 利用python读csv数据
- javafx报错not on fx application thread
- mysql事务隔离级别
- Linux常用命令汇总