%% first, cd Presentations/3_MCXLAB_Demo

cd ../3_MCXLAB_Demo

%% load a 3D volume
load digimouse.mat
img=digimouse(1:4:end,1:4:end,1:4:end); % downsample 4x to save time
imagesc(img(:,:,30));

%% call v2m and cgalmesh to convert the volume to the mesh
density=20;     %%%<--- Hands-on suggestions: change this number and see outputs
maxvol=100;     %%%<--- Hands-on suggestions: change this number and see outputs

[node,elem]=v2m(img,[],density,maxvol,'cgalmesh');

%% now check out the size of hte element list- the last column is the label
size(elem)
elem(1:4,:)

%% make the plot
figure;
plotmesh(node,elem,'x>50')
hold on
plotmesh(node,elem(elem(:,end)==18,:))
