[Insight-users] Binary image out of simple mesh
Michael Baltaxe
mbaltaxe at gmail.com
Mon Aug 27 10:56:17 EDT 2007
Hi guys,
I want to transform an itk::SimplexMesh to a binary image, which tells me
which voxels are inside and which are outside the mesh. I found an example
regarding to this in the itkSoftwareGuide, which points to
Examples/SpatialObjects/MeshSpatialObject.cxx. The problem is that the
execution of the example fails when it gets to:
myMeshSpatialObject->IsInside(myPhysicalPoint)
If I remove this line, then the execution fails in:
imageFilter->Update(); // Use the SpatialObjectToImageFilter to
create the binary image
I am using ITK 3.2.0, Visual Studio 8 2005 x64, and Windows Vista x64
(compilation is in 64 bits and debug mode, although release mode results in
the same).
In any case I tried to use the SpatialObjectToImageFilter to create the
binary image, using a SphereMeshSource in my code as follows:
m_SphereMeshSource->SetCenter(m_SeedPoint);
m_SphereMeshSource->SetScale(sphereRadius);
m_TriangleMeshToSimplexFilter->SetInput(m_SphereSource->GetOutput());
m_TriangleMeshToSimplexFilter->Update();
m_SimplexMesh = m_TriangleMeshToSimplexFilter->GetOutput();
m_SimplexMesh->DisconnectPipeline();
m_SpatialInfo = MeshSpatialObjectType::New();
m_SpatialInfo->SetMesh( m_SimplexMesh );
typedef itk::SpatialObjectToImageFilter< MeshSpatialObjectType, VolumeType >
SpatialObjectToImageFilterType;
SpatialObjectToImageFilterType::Pointer imageFilter =
SpatialObjectToImageFilterType::New();
imageFilter->SetInput( m_SpatialInfo );
imageFilter->Update();
itk::ImageFileWriter<VolumeType>::Pointer writer =
itk::ImageFileWriter<VolumeType>::New();
writer->SetFileName("foo.mhd");
writer->SetInput(imageFilter->GetOutput());
writer->Update();
But I get an image filled with 0's (ie. no voxel is inside the mesh). I know
this is not the case, because I visually check that the mesh exists and have
a size.
What am I missing here?
Thanks for your help as always,
Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070827/2990fd31/attachment.htm
More information about the Insight-users
mailing list