[Insight-users] Questions about transferring 3D model from vtkto itk.

Luis Ibanez luis.ibanez at kitware.com
Sun Sep 17 21:30:18 EDT 2006


Hi Vivian,

Please try the following:

Connect a vtkMetaImageWriter to the output of the stencil filter.
and write the image as a 3D volume.

Then visualize the image (e.g. with paraview, ImageViewer, Slicer,
VolView...) and let us now if the file contains the rasterization
of the tube.

This will allow to divide the problem between the generation of
the stencil and the actual conversion to an ITK image.


Please let us know what you find.


  Thanks


     Luis


-----------------
fyy5581 wrote:
>  
> There aren't compile problems or exceptions. The problem is I cannot 
> transfer the tube correctly to itk. I can draw the tube in VTK 
> correctly.But after it go through the itk pipeline,the result file (a 3d 
> file )have nothing in it,which expected to have a tube.
>  
> "vtkExporter - >SetInput (lum- > GetOutput());"
> shoud be
> "vtkExporter - >SetInput (stencil- > GetOutput());"
>  
> Thank you very much!
>  
> rgds,
> Vivian
> ------------------------------------------------------------------------
> fyy5581
> 2006-09-18
> ------------------------------------------------------------------------
> *发件人:* Luis Ibanez
> *发送时间:* 2006-09-14 21:32:04
> *收件人:* fyy5581
> *抄送:* insight-users
> *主题:* Re: [Insight-users] Questions about transferring 3D model from 
> vtkto itk.
>  
>  
> Hi Vivian,
>  
> 1) When you say:
>  
>     "But the first step does not work"
>  
>    Do you mean:
>  
>       1) It didn't compiled ?
>       2) It seg faulted at run time ?
>       3) It throws and exception ?
>       4) It produces an empty images ?
>       5) It produces an image of a tube with wrong dimensions ?
>  
>  
>    Please be kind and share more details with us.
>  
>  
>  
> 2) Where is the "lum" filter defined ?
>  
>   The input that you are passing to the vtkExporter filter
>   is the Output() of the "lum" object, but this object doesn't
>   appear in the rest of the code snippet that you posted.
>  
>  
>      vtkExporter - >SetInput (lum- > GetOutput());
>  
>  
>  
> 3) BTW, note that you can build a tube model directly in ITK
>    using the TubeSpatial Object, and then rasterize it into
>    an itkImage using the SpatialObject to Image filter:
>  
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1TubeSpatialObject.html
>  
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1SpatialObjectToImageFilter.html
>  
>  
>  
>  
>   Regards,
>  
>  
>  
>  
>      Luis
>  
>  
>  
> ----------------
> fyy5581 wrote:
>  > Hi all ,
>  > I have questions about transferring 3D model from vtk to itk.
>  > In fact,I want to draw a tube in vtk, and then transfer it into itk,thus 
>  > I can use raycasting to project it into an image.But the first step does 
>  > not work,which means I cannot transfer the tube I draw into itk.Can 
>  > anybody help me?Thanks a lot!!!
>  >  
>  > Vivian
>  >  
>  > Here are my code:
>  >  
>  >     //--------------------VTK pipeline-----------------------
>  > vtkLineSource* line3D = vtkLineSource::New();
>  >  line3D- >SetPoint1(0,0,0);
>  >  line3D- >SetPoint2(100,100,100); 
>  >  line3D- >Update();
>  >  
>  >  vtkTubeFilter* LineTube = vtkTubeFilter::New();
>  >  LineTube- >SetInput(line3D- >GetOutput());
>  >  LineTube- >SetNumberOfSides(8);
>  >  LineTube- >SetRadius(2);
>  >  
>  > vtkImageData* image = vtkImageData::New();
>  >  image- >SetOrigin(0,0,0);
>  >  image- >SetSpacing(0.2,0.2,0.2);
>  >  image- >SetDimensions(50,50,50);
>  >  image- >SetScalarTypeToUnsignedChar();//double to unsighned Char
>  >  image- >AllocateScalars();
>  >  image- >Update();
>  >  for (int n=0; n <image- >GetNumberOfPoints(); n++){
>  >   image- >GetPointData()- >GetScalars()- >SetTuple1(n, 127);
>  >  }
>  >  
>  >  vtkPolyDataToImageStencil * dataToStencil = 
>  > vtkPolyDataToImageStencil::New(); 
>  >  dataToStencil- >SetInput(LineTube- >GetOutput());
>  >  
>  >  vtkImageStencil* stencil = vtkImageStencil::New();
>  >  stencil- >SetInput(image);
>  >  stencil- >SetStencil(dataToStencil- >GetOutput());
>  >  stencil- >ReverseStencilOff();
>  >  stencil- >SetBackgroundValue(0); 
>  >  stencil- >Update();
>  >  
>  > // ----------------VTK-ITK-------------------------
>  > vtkImageExport* vtkExporter = vtkImageExport::New();
>  >  vtkExporter - >SetInput (lum- > GetOutput());
>  > 
>  >  typedef itk::Image <unsigned char, 3 > ImageType;
>  >  typedef itk::VTKImageImport <ImageType > ImageImportType; 
>  >  ImageImportType::Pointer itkImporter = ImageImportType::New(); 
>  >  
>  >  ConnectPipelines(vtkExporter, itkImporter);  //it's code comes from 
>  > connectPipelines in VTKUtility.h  in 
>  >                                                             // 
>  > insightApplication
>  >  
>  >     //--------------------ITK pipeline-----------------------
>  >  typedef itk::RescaleIntensityImageFilter < ImageType, ImageType  > 
>  > rescalefilterType;
>  >  rescalefilterType::Pointer itkrescaler = rescalefilterType::New(); 
>  >  itkrescaler- >SetInput(itkImporter- >GetOutput());
>  >  itkrescaler- >SetOutputMinimum(0);
>  >  itkrescaler- >SetOutputMaximum(65535);
>  >  
>  >  typedef itk::ImageFileWriter < ImageType  > WriterType;
>  >  WriterType::Pointer writer = WriterType::New();
>  >  
>  >  typedef itk::VTKImageIO    ImageIOType;
>  >  ImageIOType::Pointer vtkIO = ImageIOType::New();
>  >  
>  >  writer- >SetFileName(".\tubelineOutput.vtk");
>  >  writer- >SetInput(itkrescaler- >GetOutput()); 
>  >  
>  >  vtkIO- >SetFileTypeToASCII();
>  >  writer- >SetImageIO( vtkIO );
>  > 
>  >   writer- >Update();
>  >  
>  > ...
>  > ------------------------------------------------------------------------
>  > fyy5581
>  > 2006-09-12
>  > 
>  > 
>  > ------------------------------------------------------------------------
>  > 
>  > _______________________________________________
>  > 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