[Insight-users] Binary image out of simple mesh
Luis Ibanez
luis.ibanez at kitware.com
Mon Aug 27 12:04:47 EDT 2007
Hi Michael,
You may want to use the following filter:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1TriangleMeshToBinaryImageFilter.html
Rasterizing a Mesh is not as fast as to be
implemented correctly in the IsInside method
of the StatialObject family.
Instead you may want to explicitly use the filter
recommended above.
Regards,
Luis
------------------------
Michael Baltaxe wrote:
> 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.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list