vmtklevelsetsegmentation and vmtkmarchingcubes

184 views
Skip to first unread message

Jesse Ross-Jones

unread,
Nov 19, 2013, 6:29:46 AM11/19/13
to vmtk-...@googlegroups.com
Dear VMTKrs,
I am trying to write a C++ program to segment and create a mesh object using vmtk. I am using the following as reference:

vmtklevelsetsegmentation -ifile image_volume_voi.vti --pipe vmtkmarchingcubes -i @.o -ofile model.vtp

Right now I would like simply to use the thresholding
initialization type, however I have trouble following the vmtklevelsetsegmentation python script

My attempt to recreate it is pasted here: http://pastebin.com/rMdsCpgv. Right now I am getting this error: Input port 0 of algorithm vtkvmtkThresholdSegmentationLevelSetImageFilter(08416068) has 0 connections but is not optional.

I know i somehow need to provide an initialization image and I guess this is the origin of the error..

Could someone please help me understand a little better how to use vtkvmtkThresholdSegmentationLevelSetImageFilter.h?

Many many thanks
Jesse


Luca Antiga

unread,
Nov 19, 2013, 5:14:50 PM11/19/13
to vmtk-...@googlegroups.com
Hi Jesse,
 I suggest you take a look at this:
and this

since the vmtk class is a wrapper around that ITK class.

Basically the threshold segementation level set image filter is a level set evolution filter that starts from some implicit surface (an image negative inside and positive outside the shape, or the other way around, it's just a convention, whose zero isosurface is the surface you're evolving) and inflates or deflates until it falls within an intensity range given by the lower and upper thresholds. The portion of the surface located in regions of the image that are greater than the upper threshold will deflate, while the portion located in regions lower than the lower threshold will inflate.

The initialization is provided through the call to SetInput and the initial isovalue used to define the initial level set is the one specified in SetIsoSurfaceValue (0.0 in your case, so just make sure your image crosses zero somewhere).

You have SetInput in your code, so you're doing it correctly. Try to call connector->Update() somewhere, e.g. before you set its output as input to the threshold level set filter - it might be a pipeline issue.

Best,

Luca



--
You received this message because you are subscribed to the Google Groups "vmtk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vmtk-users+...@googlegroups.com.
To post to this group, send email to vmtk-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Luca Antiga, PhD
Co-founder and Principal Scientist, OROBIX Srl
via L.A. Muratori 3, 24123 Bergamo, Italy

twitter: @lantiga

"This message originates from OROBIX Srl and its contents and attachments are privileged and confidential and are intended only for the individual(s) or entity(ies) named above. This message should not be forwarded, distributed or disclosed. Any unauthorized use, dissemination and duplication is strictly prohibited and may be unlawful. All personal messages express views solely of the sender, which are not to be attributed to OROBIX Srl, and may not be copied or distributed without this disclaimer. If you are not the intended recipient or received this message in error, please delete this message and notify the sender by reply e-mail. Opinions, conclusions and other information in this message that do not relate to the official business of OROBIX Srl shall be understood as neither given nor endorsed by it."

Jesse Ross-Jones

unread,
Nov 21, 2013, 5:04:58 AM11/21/13
to vmtk-...@googlegroups.com
Hi Luca,
Many thanks for the example and explanation.

I have used that example to generate the attached source code and to generate levelsetTest.vti but when I compare this to the output generated by vmtk(levelsetTestVMTK.vti) it is slightly different but I dont know the cause(could it be from how the image is initialized?). Also when I try to use this file to generate a surface using marching cubes (vmtkmarchingcubes -ifile C:/temp/VMTK_testing/levelsetTest.vti -ofile C:/temp/VMTK_testing/model.vtp )  there is no result (empty polydata). Is there a problem with the parameters I am using perhaps, or the initialization of the image? In this case to initialize I am using a distance map generated by the Danielsson filter.

Many thanks,
Jesse
levelsetTest.vti
levelsetTestVMTK.vti
vmtklevelSetSegmentation.cxx

Luca Antiga

unread,
Nov 30, 2013, 12:41:01 PM11/30/13
to vmtk-...@googlegroups.com
Hi Jesse,
 I got around to looking at the data only today.

So, your output image is essentially binary, all voxels are either 0 or 255. This is because you are using

thresholdSegmentation -> thresholdFilter -> writer

The thresholdFilter takes the output from the level set segmentation and binarizes it, which I don't think is what you want if you want to make it look similar to vmtk. 

vmtk outputs a level set, which is an image that has < 0 values inside and > 0 values outside the surface, typically floating point, so that interpolating the 0-isosurface you can get a smooth surface (otherwise you'd see it minecraft-like, as in your output).

Just try to get rid of the thresholdFilter and connect the segmentation filter directly to the writer. Also, use a larger number of iterations, 1 will not do much.

Hope this helps.

Luca 
Reply all
Reply to author
Forward
0 new messages