Home > vbmeg > external > iso2mesh > sample > demo_helloworld.m

demo_helloworld

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Hello World - The "getting started" example of iso2mesh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 % Hello World - The "getting started" example of iso2mesh
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 
0005 % In this example, we illustrate the basic mesh density and precision
0006 % controls in iso2mesh.
0007 
0008 %% the first step is to load a binary or gray-scale image
0009 
0010 hw=imread('helloworld.png');
0011 
0012 % now we stack the image and form a binary volume
0013 
0014 hw3d=1-repmat(hw,[1 1 50]);
0015 
0016 %% create 3D mesh          |--------> threshold at v=0.7
0017 [node,elem,face]=v2m(hw3d,0.7,5,40);
0018 %                             |  |-> maximum volume
0019 %                             |----> maximum surface triangle size
0020 
0021 figure;
0022 subplot(211);
0023 plotmesh(node,face);axis equal;view(90,60);
0024 subplot(212);
0025 plotmesh(node,elem,'z<20');axis equal;view(90,60);
0026 
0027 % mesh with denser surface    |----> surface triangle size is now 2
0028 [node,elem,face]=v2m(hw3d,0.7,2,40);
0029 
0030 figure;
0031 subplot(211);
0032 plotmesh(node,face);axis equal;view(90,60);
0033 subplot(212);
0034 plotmesh(node,elem,'z<20');axis equal;view(90,60);
0035 
0036 %% create 3D mesh from gray-scale image to get smoother boundary
0037 hw=imread('helloworld_gray.png');
0038 hw3d=255-repmat(hw,[1 1 50]);
0039 [node,elem,face]=v2m(hw3d,128,2,40);
0040 
0041 figure;
0042 subplot(211);
0043 plotmesh(node,face);axis equal;view(90,60);
0044 subplot(212);
0045 plotmesh(node,elem,'z<20');axis equal;view(90,60);
0046 
0047 %% create 3D mesh from gray-scale image with advanced distbound control
0048 clear opt
0049 opt.radbound=4;       % set surface triangle maximum size
0050 opt.distbound=0.2;    % set max distance that deviates from the level-set
0051 opt.autoregion=1;
0052 [node,elem,face]=v2m(hw3d,128,opt,40);
0053 
0054 figure;
0055 subplot(211);
0056 plotmesh(node,face);axis equal;view(90,60);
0057 subplot(212);
0058 plotmesh(node,elem,'z<20');axis equal;view(90,60);
0059

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005