[Insight-users] input mesh to TriangleMeshToBinaryImageFilter

Leila Baghdadi baghdadi at sickkids.ca
Tue Sep 12 13:43:53 EDT 2006


Hi

one thing to consider is to make sure your image is large enough for the
mesh. i.e, make sure the image and the mesh overlap in space. 

I have used this class on my own studies and did not have any
difficulties.

HTH

Leila

On Tue, 2006-12-09 at 19:05 +0800, advanced math wrote:
> Dear All,
> 
>   I got some problems when using the TriangleMeshToBinaryImageFilter
> class,
> 
>   The following test code can run smoothly,
> 
>   typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double>
> TriangleMeshTraits;
>   typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType; 
>   typedef
> itk::RegularSphereMeshSource<TriangleMeshType>  SphereMeshSourceType;
>   typedef SphereMeshSourceType::PointType PointType; 
>   typedef itk::Image<unsigned char, 3>      MeshPixelType;
>   typedef itk::TriangleMeshToBinaryImageFilter<TriangleMeshType,
> MeshPixelType> TriangleMeshToBinaryImageFilterType;
> 
>   TriangleMeshToBinaryImageFilterType::Pointer m_TriangleMeshToImage =
> TriangleMeshToBinaryImageFilterType::New();
> 
> 
> PointType center; 
> center[0]=200;
> center[1]=200;
> center[2]=200;
> 
> SphereMeshSourceType::Pointer mySphere = SphereMeshSourceType::New();
> mySphere->SetCenter(center);
> mySphere->SetScale( 10 );
> mySphere->SetResolution(5);
> 
> m_TriangleMeshToImage->SetInput(mySphere->GetOutput());
> 
> MeshPixelType::SizeType size;
> 
> size[0] = 90;
> size[1] = 90;
> size[2] = 90;
> m_TriangleMeshToImage->SetSize(size);
> 
> float orgn[3];
> orgn[0] = 120;
> orgn[1] = 120;
> orgn[2] = 120;
> m_TriangleMeshToImage->SetOrigin(orgn);
> 
> // spacing remains (1,1,1) until we make a change to deformable model
> class
> float spacing[3];
> spacing[0] = 1;
> spacing[1] = 1;
> spacing[2] = 1;
> 
> m_TriangleMeshToImage->SetSpacing(spacing);
> 
> m_TriangleMeshToImage->Update(); 
> 
> 
> However, when I change the input mesh to itk::mesh as the following
> code, runtime exception occurred in the itkprocessobject.
> 
>   typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double>
> TriangleMeshTraits;
>   typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType; 
>   typedef itk::Image<unsigned char, 3>      MeshPixelType;
>   typedef itk::TriangleMeshToBinaryImageFilter<TriangleMeshType,
> MeshPixelType> TriangleMeshToBinaryImageFilterType;
> 
>   TriangleMeshToBinaryImageFilterType::Pointer m_TriangleMeshToImage =
> TriangleMeshToBinaryImageFilterType::New();
>   TriangleMeshType::Pointer m_TriangleMesh =
> TriangleMeshType::New(); //Mesh in triangle
>   ..................................
>   .................................
>  (The code to add point and triangle cell into the mesh) 
>  .................................
>  ................................... 
> m_TriangleMeshToImage->SetInput(m_TriangleMesh);
> 
>   MeshPixelType::SizeType size;
> 
> size[0] = 90;
> size[1] = 90;
> size[2] = 90;
> m_TriangleMeshToImage->SetSize(size);
> 
> float orgn[3];
> orgn[0] = 120;
> orgn[1] = 120;
> orgn[2] = 120;
> m_TriangleMeshToImage->SetOrigin(orgn);
> 
> // spacing remains (1,1,1) until we make a change to deformable model
> class
> float spacing[3];
> spacing[0] = 1;
> spacing[1] = 1;
> spacing[2] = 1;
> 
> m_TriangleMeshToImage->SetSpacing(spacing);
> 
> m_TriangleMeshToImage->Update();
> 
> In case there is error in creating the mesh, I have output the mesh in
> meta file, and checked. No problems found. 
> Any ideas? Thanks.
> 
> Tim,
> _______________________________________________
> 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