[ITK Community] [Insight-users] Bls: how to write *.vtk file

Jaume jaumesastretomas at gmail.com
Tue Feb 25 12:08:42 EST 2014


SUTRISNO SUTRISNO <sutrisno_link at ...> writes:

> 
> 
> 
>  Hi luis,I already knew how to write polydata. now the problem is how to 
extract  surface of the image. is my code true?There is no problem when I 
compile, but when I display the surface (bone.vtk) it's not appear as a 
surface. my code : typedef itk::Mesh<double>                         
MeshType;
>   typedef itk::BinaryMask3DMeshSource< ImageType, MeshType >   
MeshSourceType;
>     MeshSourceType::Pointer meshSource = MeshSourceType::New();
> 
>     const PixelType objectValue = static_cast<PixelType>( 1250 
);                       meshSource->SetObjectValue( objectValue );
>     meshSource->SetInput( reader->GetOutput() );
>   
>   typedef itk::VTKPolyDataWriter< MeshType > WriterType;
>     WriterType::Pointer writer = WriterType::New();
>     writer->SetFileName( "bone.vtk" );
> 
>     writer->SetInput( meshSource->GetOutput() );
>     writer->Update();Regards, Sutrisno
> Dari: Luis Ibanez <luis.ibanez-
5opLkZggLXlBDgjK7y7TUQ at public.gmane.org>Kepada: SUTRISNO SUTRISNO 
<sutrisno_link at yahoo.com>Cc: itk <Insight-
users at itk.org>Terkirim: Kam, 6 Mei, 2010 22:46:44Judul: 
Re: how to write *.vtk fileHi Sutrisno,The problem is that you are passing 
an Image as the input to the PolyData writer. The Writer expects that its 
input will be an itkMesh.Please look at the following files, as 
> examples of usage:  Insight/Testing/Code/Review/      
itkVTKPolyDataWriterTest2.cxx      itkVTKPolyDataWriterTest.cxx   
Regards,        Luis--------------------------------------------------------
-----------On Thu, May 6, 2010 at 11:38 AM, SUTRISNO SUTRISNO 
<sutrisno_link at yahoo.com> wrote:
> 
> Hi luis,You said that If I want to save surface  I must extract an itkMesh 
out of the image. When I try extract surface from image (use 
SurfaceExtraction.cxx) 
> there was error :error: no matching function for call to
> ‘itk::VTKPolyDataWriter<itk::Mesh<double, 3u,
> itk::DefaultStaticMeshTraits<double, 3u, 3u, float, float,
> double> > >::SetInput(itk::OrientedImage<short int,
> 3u>*)’
> /usr/local/include/InsightToolkit/Review/itkVTKPolyDataWriter.txx:54:
> note: candidates are: void
> itk::VTKPolyDataWriter<TInputMesh>::SetInput(const TInputMesh*)
> [with TInputMesh = itk::Mesh<double, 3u,
> itk::DefaultStaticMeshTraits<double, 3u, 3u, float, float,
> double> >]my Listing :  typedef itk::Mesh<double>                         
MeshType;
>   typedef itk::BinaryMask3DMeshSource< ImageType, MeshType >   
MeshSourceType;
>     MeshSourceType::Pointer meshSource = MeshSourceType::New();
> 
>     const PixelType objectValue = static_cast<PixelType>( 1250 
);                       meshSource->SetObjectValue( objectValue );
>     meshSource->SetInput( reader->GetOutput() );
>   
>   typedef itk::VTKPolyDataWriter< MeshType > WriterType;
>     WriterType::Pointer writer = WriterType::New();
>     writer->SetFileName( argv[2] );
> 
>     writer->SetInput( reader->GetOutput() );
>     writer->Update(); Regards,         Sutrisno
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 

I'm having the same trouble than my friend:

I have a .tiff 3D file that I read.

I use a ThresholdImageFilter to binarize the image.

I use the output of the ThresholdImageFilter as an imput of the 
BinaryMask3DMeshSource mesh.

I want then to save this mesh as an .ITK file but I can't. I'm using 
VTKPolyDataWriter but it doesn't accept the mesh type that I've used.



There is my ITK code:
const unsigned int Dimension = 3;
typedef itk::Mesh< float, Dimension >   MeshType;

typedef itk::BinaryMask3DMeshSource< InternalImageType, MeshType >   
MeshSourceType;
MeshSourceType::Pointer meshSource = MeshSourceType::New();

meshSource->SetInput(imageInput); // It's the output of a threshold
meshSource->Update();

// Write the mesh to a file
typedef itk::VTKPolyDataWriter< MeshSourceType >   WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( meshSource );
writer->SetFileName( pathFilenameOut );
writer->Write();

Any help will be really apreciated!

Thanks

Kind regards

James

_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list