1 Star 0 Fork 0

Roger-Luo/vrn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rendervol.m 797 Bytes
一键复制 编辑 原始数据 按行查看 历史
function img = rendervol(imgpath, volpath, texture)
% Renders a volume which has been generated by the VRN lua script.
vol = readvol(volpath, [192 192 200]);
im = imread(imgpath);
Q = isosurface(vol);
Q.vertices(:,3) = Q.vertices(:,3) * 0.5;
Q.EdgeColor = 'none';
Q.FaceColor = [120 154 194]/255;
if texture
red = double(im(:,:,1));
green = double(im(:,:,2));
blue = double(im(:,:,3));
[vcx,vcy] = meshgrid(1:192,1:192);
vc = [vcx(:) vcy(:) red(:) green(:) blue(:)];
cols = knnsearch(vc(:,1:2), Q.vertices(:,1:2));
Q.FaceVertexCData = uint8(vc(cols,3:5));
Q.FaceColor = 'interp';
end
figure
imshow(im, 'Border', 'tight');
hold on
patch(Q);
hold on
h = camlight;
lightangle(h, -10, 80)
lighting gouraud
material dull
view(0,90)
cap = getframe;
img = cap.cdata;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/roger521/vrn.git
git@gitee.com:roger521/vrn.git
roger521
vrn
vrn
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385