资源描述:
《图像透明度和纹理贴图的matlab实现》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、file:///C
2、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-1.txt[xyzv]=flow;p=patch(isosurface(x,y,z,v,-3));isonormals(x,y,z,v,p);set(p,'facecolor','red','edgecolor','none');daspect([111]);view(3);axistight;gridon;camlight;lightinggouraud;file:///C
3、/DocumentsandSettings/A
4、dministrator/桌面/代码/第8章/代码8-1.txt[2011-5-1611:13:44]file:///C
5、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-2.txt[x,y]=meshgrid([-2:.2:2]);z=x.*exp(-x.^2-y.^2);surf(x,y,z,gradient(z));axistightfile:///C
6、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-2.txt[2011-5-1611
7、:13:44]file:///C
8、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-3.txtplot(alphamap('vup'))alphamap('increase',.4)plot(get(gcf,'Alphamap'))file:///C
9、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-3.txt[2011-5-1611:13:45]file:///C
10、/DocumentsandSettings/Administrator/桌面
11、/代码/第8章/代码8-4.txt[x,y,z]=meshgrid(-1.25:.1:-.25,-2:.2:2,-2:.1:2);v=x.*exp(-x.^2-y.^2-z.^2);h=slice(x,y,z,v,[-1-.75-.5],[],[0]);alpha('color')set(h,'EdgeColor','none','FaceColor','interp',...'FaceAlpha','interp')alphamap('rampdown')alphamap('increase',.1)colormap(hsv)file:/
12、//C
13、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-4.txt[2011-5-1611:13:45]file:///C
14、/DocumentsandSettings/Administrator/桌面/代码/第8章/代码8-5.txt%取得一个图像采集装置的使用权。vidobj=videoinput('winvideo',1,'RGB24_320X240');%使用预览窗口,适当定位摄像头。.preview(vidobj)pause(1)%采集没有运动的背景图像。background=ge
15、tsnapshot(vidobj);%将图像background的数据类型由uint8转换到double。background=double(background)/255;%在一个图形窗口中显示图像background。imagesc(background);%将物体置入运动状态。pause(2);%设置捕获图形窗口以便生成动态渲染。set(gcf,'DoubleBuffer','on');%设置捕获设备。vidobj.FramesPerTrigger=20;%开始图像捕捉。start(vidobj)%当载入数据时,实现当前图像和背景图像
16、的线性混合。current=getdata(vidobj,1,'double');transparent=(current*0.5)+(background*0.5);%显示处理后的图像。imagesc(transparent);%对所有后续图像进行相同的处理。while(vidobj.FramesAvailable>0),%实现当前图像和背景图像的线性混合。current=getdata(vidobj,1,'double');transparent=(current*0.5)+(background*0.5);%显示处理后的图像。imag
17、esc(transparent);end%当不再需要视频输入对象时,从workspace中对其进行删除和清除处理。delete(vidobj)clearvidobjfile://