[Insight-users] input mesh to TriangleMeshToBinaryImageFilter

advanced math advanced.math at gmail.com
Tue Sep 12 07:05:51 EDT 2006


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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060912/35f37b4d/attachment-0001.html


More information about the Insight-users mailing list