specify voxel size dimensions

195 views
Skip to first unread message

Wendy van de Ven

unread,
Aug 9, 2011, 4:08:07 AM8/9/11
to iso2mesh-users
Hi,

I currently have some binary 3D image data in a tiff-file. I can
import this data into Matlab and build a mesh from it using the v2m
function with cgalmesh option.
However, when displaying the image in Matlab, the voxel coordinates
are used and real sizes are lost. This means that the dimensions used
for the mesh are not correct.
Is it possible to include information about the voxel size?

Thanks,
Wendy

Qianqian Fang

unread,
Aug 9, 2011, 8:37:09 AM8/9/11
to iso2mes...@googlegroups.com, Wendy van de Ven

hi Wendy

v2m and v2s accept opt.A and opt.B to apply a linear transformation
to the generated mesh. Assuming a mesh node p={x,y,z}, the
transformed coordinate is
p_new=opt.A*p+B
where A is a 3x3 matrix, B is a 3x1 vector.

using such matrix, one can encode scaling, translation, and
rotation to the resulting mesh. For example, if you want to
scale the mesh by a factor of 2, you simply set
opt.A=diag([2,2,2]); opt.B=zeros(3,1);

In fact, because setting voxel size is quite simply, you can
even run the scaling separately from v2m. A single line of
code should be suffice.

Qianqian

>
> Thanks,
> Wendy
>

Qianqian Fang

unread,
Aug 9, 2011, 9:54:42 AM8/9/11
to Wendy van de Ven, iso2mes...@googlegroups.com
On 08/09/2011 09:17 AM, Wendy van de Ven wrote:
Hi Qianqian,
 
opt.A and opt.B do not seem to work with the option 'cgalmesh'
I can use 'cgalsurf', but as I am working with multi-region binary images 'cgalmesh' works nicer.
Can opt.A and opt.B be easily included in 'cgalmesh'?

hi Wendy

I just committed a small patch to allow you to use opt.A/B in
cgalmesh, see

https://orbit.nmr.mgh.harvard.edu/plugins/scmsvn/viewcvs.php/trunk/iso2mesh/cgalv2m.m?root=iso2mesh&r1=293&r2=299

alternatively, you can do this as a post process, like

[node, elem, face]=v2m(...);
node(:,1:3)=(A*node(:,1:3)'+repmat(B(:),1,size(node,1)))';

where A and B represent the linear transformation.

Qianqian

 
Thanks,
Wendy

2011/8/9 Qianqian Fang <fan...@gmail.com>

Dmitry Sorokin

unread,
Sep 30, 2015, 12:09:48 PM9/30/15
to iso2mesh-users, venw...@gmail.com
Dear Qianqian,

I decided to write it here not to create another topic.
I'm working with 3D cell image data and I've faced the problem with the voxel size.
The solution you suggested here with scaling has kinda drawback for my data.

So in my data the voxel size in Z axis is ~2.8 times bigger than in X and Y. Thus when I use opt.A = diag( [0.3528    0.3528    1.0000] ) I get tetrahedra that are significantly elongated in Z direction (see scaling.jpg) that is not nice for the latter processing of the data in my case.

That's why I also tried to do the following. I resampled the initial image in Z direction, namely duplicated each slice of my data round(2.8) = 3 times. In this way the tetrahedra are more isotropic in all dimensions (see resampling.jpg). But using this way I'm losing precision as I can't properly resample my image in 2.8 times.

Is there any way to make cgal take into account the actual size of voxels on the stage of creating the mesh? Some of my colleagues use cgal library for meshing in other software and they claimed that cgal can take into account the voxel size, however I haven't found anything about that in their manuals.

I think that may be a common issue because sometimes the difference in 3D image dimensions can be even 5-6 times that would make the resulting mesh very nonuniform...

The example data, scripts and figures are attached.
Thanks in advance!

--Dmitry
data.mat
resampling.fig
resampling.jpg
scaling.fig
scaling.jpg
script.m
Reply all
Reply to author
Forward
0 new messages