v2s stuck when generating meshes from volumes with few voxels

25 views
Skip to first unread message

Changran Geng

unread,
Mar 18, 2023, 3:02:25 AM3/18/23
to iso2mesh-users
Dear everyone,

I found the code got stuck when I using v2s to generate surface mesh using v2s from a volume with few voxels (<100), e.g. the eye of humans/animals. An example of my testing code below.

I am quite new about the modeling and mesh generation.
Do you have any suggestions on this problem?

Thank you very  much for any help and kind suggestions.
Best regards,
Changran
 
#############
Below is the code, attached the volume data in the google drive(https://drive.google.com/file/d/1F5sppKN2MlvAC2dOW2-XYNcMkYokl6tM/view?usp=share_link).
 
load('small_organ.mat');
clear opt;
 
i=1;
opt(i).keepratio=1; % resample levelset 1 to 5%
pix_no=length(find(small_organ(:)==i));
fprintf('pixel number : %d\n',pix_no);
opt(i).side='lower'; %
 opt(i).maxnode=1000;
opt(i).radbound=1; % set surface triangle maximum size
opt(i).distbound=0.2; % set max distance that deviates from the level-set
opt(i).A=diag([0.9,0.7,3]);
opt(i).B=[0 0 0];

[no,fc]=v2s(small_organ,1, opt);

figure
plotmesh(no(:,[2 1 3]),fc,'facealpha',0.7);
[node,elem]=s2m(no,fc,1,100);
 figure
plotmesh(node,elem,'y>150');axis equal;view(90,60);


Qianqian Fang

unread,
Mar 18, 2023, 10:11:57 AM3/18/23
to iso2mes...@googlegroups.com, Changran Geng

I was able to run your code, and noticed a number of issues


First, your domain is relatively large 512 x  512 x  158 but 99% of the volume is empty. your non-zero voxel is only a few voxels. this is not the best way to mesh such tissue from multiple perspectives. First, it is very inefficient. the meshing tools had to analyze all the voxels to create mesh, but most of them do not contain boundary information. Secondly, the relative resolution to your non-zero region is very poor, because the non-zero voxels is only about 5x4x3 voxels in size, the discretization error (voxel-like stair-case boundaries) is dominant. You should at least cut out most of the empty space to make the meshing process fast. If possible, increase the resolution for the non-zero label region.

to find out where are your non-zero voxels, you can run (see left panel of the attached image)

[no,fc]=binsurface(small_organ);
plotmesh(no, fc)


also, if you crop your domain to only the non-zero voxel regions, you can get the mesh less than a second (see right panel of the attached image)

[no,fc]=v2s(small_organ(90:102, 265:280, 100:105), 0.5,opt);
plotmesh(no,fc)


but again, your resolution is super coarse so the shape you saw was mostly dominant by voxelation, not really an accurate surface.


Secondly, your v2s parameter setting is problematic. For v2s, the isovalue input is meant to be between your discrete values. if you have 0 and 1 values, the better isovalue to use is 0.5. yet you used 1.

Qianqian


--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iso2mesh-users/132218b8-13ff-41e3-bf1e-01b5e4a8913fn%40googlegroups.com.

Changran Geng

unread,
Mar 18, 2023, 12:06:00 PM3/18/23
to iso2mesh-users
Dear Prof. Fang,

Thank you. Your suggestions are valuable.
Using your command really works, but I got a figure like below. How did you get the smoothed plot?

Thanks,
Changran


WX20230319-000031@2x.png

Qianqian Fang

unread,
Mar 18, 2023, 12:15:35 PM3/18/23
to iso2mes...@googlegroups.com, Changran Geng

increase your opt.distbound value will create a smoother surface. distbound is the distance deviates from the true voxelated boundary. the smaller the value, the more voxel-like the output mesh will be.

you can also increase opt.radbound, but because your domain is so small, large radbound will give a very sparse mesh.

Changran Geng

unread,
Mar 18, 2023, 12:18:41 PM3/18/23
to Qianqian Fang, iso2mes...@googlegroups.com
That make sense. Thank you for your kind help.
Have a nice weekend.

Changran
Reply all
Reply to author
Forward
0 new messages