hi Luca
the first step is to segment your 2D image into vessel vs background, and convert it to a binary mask. Then, you can apply a similar process like I posted in this reply
https://groups.google.com/d/msg/iso2mesh-users/4wgNaBKQZFM/ccYfSw4UCwAJ
if your goal is to create a 3D mesh, you can just do the first 2 lines, i.e. repmat and then v2m.
you can also see a similar meshing process in this "Hello World" demo script
https://github.com/fangq/iso2mesh/blob/master/sample/demo_helloworld.m#L36-L39
one thing I did previously was to apply bwmorph(img, 'erode', 1) for each layer you extend the image along the z-axis, as you move away from the center slice. This will give you a square-shaped vessel. You can adjust the erosion rate to make it more circular in the z-axis, but it won't be perfect.
Qianqian
--
Thanks,Luca
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 post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
For more options, visit https://groups.google.com/d/optout.
On 4/30/19 11:28 AM, gian...@gmail.com wrote:
Hi all,
I have a 2D grayscale image (I attached the file of the image) and I would like to create a 3D mesh out of it, by simply extending the image along the vertical direction to create a 3D volume.
My idea was to use repmat to create the volume from the image matrix and then covert it into mesh using v2m. However, how can I control the size of the mesh I want to create from the 3D volume? Ideally I would like a 1x1x2 mm meshed slab.Is that achievevable?
hi Luca
the first step is to segment your 2D image into vessel vs background, and convert it to a binary mask. Then, you can apply a similar process like I posted in this reply
https://groups.google.com/d/msg/iso2mesh-users/4wgNaBKQZFM/ccYfSw4UCwAJ
if your goal is to create a 3D mesh, you can just do the first 2 lines, i.e. repmat and then v2m.
you can also see a similar meshing process in this "Hello World" demo script
https://github.com/fangq/iso2mesh/blob/master/sample/demo_helloworld.m#L36-L39
one thing I did previously was to apply bwmorph(img, 'erode', 1) for each layer you extend the image along the z-axis, as you move away from the center slice. This will give you a square-shaped vessel. You can adjust the erosion rate to make it more circular in the z-axis, but it won't be perfect.
Qianqian
--
Thanks,Luca
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 iso2me...@googlegroups.com.
To post to this group, send email to iso2me...@googlegroups.com.
I=imread('Mouse_brain_picture.png');I=rgb2gray(I);img=imbinarize(I,'adaptive'); % Convert grayscale image into binary mask;img=bwmorph(img,'erode',1); % Smooth binary mask;vol=repmat(img,1,1,10);[node,elem,face]=v2m(vol,1,2,10);
hi Luca
please see my below script and attached screenshots
I=imread('binary.tif');
I=rgb2gray(I);
img=imbinarize(I,'adaptive'); % Convert grayscale image into binary mask;
vol=repmat(img,1,1,21);
for i=1:10
vol(:,:,11+i)=bwmorph(vol(:,:,11+i),'erode',i);
vol(:,:,11-i)=vol(:,:,11+i);
end
[node,elem,face]=v2m(uint8(vol+1),[],8,100, 'cgalmesh');
figure;
plotmesh(node,elem,'x>100')
figure;
plotmesh(node,elem(elem(:,5)==2,:))
Not entirely sure what's the squared frame outside of your vessel, but you can easily separate it after.
I first stack the 2d image into a 3D volume, and then I erode each layer differently, then I created a square-shared cross-section, see the 2nd mesh plot.
another way to do this is to keep the image in gray-scale, and use v2s() first to extract the vessel surface, then add a non-intersecting bounding box using meshabox and surfboolean (if intersecting)/mergemesh (if not intersecting), then call s2m to create
the final mesh. the quality is better if you do this way, but the cgalmesh output might just be sufficient (if you don't need to apply smoothing or control the node densities).
Qianqian
--
Luca
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 post to this group, send email to iso2mes...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2me...@googlegroups.com.
To post to this group, send email to iso2me...@googlegroups.com.
Thank you!
If I run the script myself on my platform, I don't actually get the strange frame!
glad to know
I have a last question: Is there a way to control the size (width x height x depth) of the final mesh or does it depend only on the size of the 3D volume? I would like to have a 1.2 mm x 1.2 mm x 1.2 mm mesh (and perhaps add some extra depth made only of background medium (no vessels) in the z direction up to 1 cm).
if you are referring to the aspect ratio of the generated mesh, if the aspect ratio is not too different from 1 (let's say <50% difference), then, a simple scaling should be fine, you can define
A=diag([1.2, 0.8, 1.1]);
node(:,1:3)=(node(:,1:3)*A);
if the aspect ratio is relatively big, you should use imresize() to resize the domain, preferably downsampling, and then create the mesh based on the properly resampled volume.
hope this helps.
Qianqian
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/iso2mesh-users/e853f051-59d2-4b71-bf1b-23d12222eff2%40googlegroups.com.