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

demo_label_sizing

PURPOSE ^

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

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 specify maximum cell sizes for different labels
 (this is only valid when using 'cgalmesh' with v2m or vol2mesh)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 % specify maximum cell sizes for different labels
0003 % (this is only valid when using 'cgalmesh' with v2m or vol2mesh)
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 
0006 % create a dummy image
0007 
0008 rad = 10:10:50;
0009 maxRad = max(rad);
0010 box = zeros(maxRad+1,maxRad+1,maxRad+1);
0011 image = box;
0012 box(1,1,1) = 1;
0013 %DT = bwdist(box,'euclidean');
0014 [ix,iy,iz]=meshgrid(1:maxRad+1,1:maxRad+1,1:maxRad+1);
0015 DT = sqrt((ix - 1).*(ix -1) + (iy - 1).*(iy -1) + (iz - 1).*(iz -1));
0016 
0017 for i = 1:size(rad,2)
0018     ball = DT<=rad(i);
0019     image(ball~=0) = image(ball~=0) + ball(ball~=0);
0020 end
0021 
0022 image = uint8(image);
0023 
0024 % mesh the domain with different sizing options
0025 
0026 figure;
0027 maxvol='1';
0028 [no,el]=v2m(image,[],5,maxvol,'cgalmesh');
0029 subplot(221);
0030 plotmesh(no(:,1:3),el,'x-y<0');
0031 title('a single scalar sets cell size for all labels');
0032 
0033 maxvol='1=2:2=1:3=2:4=1';
0034 [no,el]=v2m(image,[],5,maxvol,'cgalmesh');
0035 subplot(222);
0036 plotmesh(no(:,1:3),el,'x-y<0');
0037 title(sprintf('maxvol is "%s"',maxvol));
0038 
0039 maxvol='2:1:2:1';
0040 [no,el]=v2m(image,[],5,maxvol,'cgalmesh');
0041 subplot(224);
0042 plotmesh(no(:,1:3),el,'x-y<0');
0043 title(sprintf('maxvol is "%s", same as above',maxvol));
0044 
0045 maxvol='3=2:1:0.5';
0046 [no,el]=v2m(image,[],5,maxvol,'cgalmesh');
0047 subplot(223);
0048 plotmesh(no(:,1:3),el,'x-y<0');
0049 title(sprintf('maxvol is "%s", same to 3=2:4=1:5=0.5',maxvol));
0050

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