[Insight-users] Help with conversion itk vtk

Luis Ibanez luis.ibanez at kitware.com
Sat Jun 28 21:53:56 EDT 2008


Hi Lolo,

Please look at the examples in

             InsightApplications/Auxiliary/vtk

in particular to

      itkReadITKImage3DSegmentShowVTK.cxx
      itkReadITKImageSegmentShowVTK.cxx
      itkReadITKImageShowSplineVTK.cxx
      itkReadITKImageShowVTK.cxx

The example

      itkReadITKImageShowVTK.cxx

has most of what you need.



Regards,


     Luis



--------------------
lolo lolailo wrote:
> Hi
> 
> I'm triying to convert an Image that I've created with itk and it pass a 
> process to apply confidenceconected filter to vtk.
> 
> The problem is that when i see the image after the conversion it is draw 
> the planes xz and yz in the limit of image
> 
> if we use axial view we can see the connected image ( X is supposed to 
> be the image) and somwething like that:         
> _____                                                                   
>                                                                         
>                                                                         
>                       |                                                 
>                                                                          
>                                    
>   X    |
>                                                                       
>                                                                
> 
> and i need to see the image without planes xz yz
> 
> 
> here is the code if it can serve as aid
> 
>     ///The application is developed in visual studio an using a GUI
> 
>     const     unsigned int    Dimension = 3;
> 
>     typedef   float           PixelType;
>     typedef itk::Image< PixelType, Dimension >  ImageType;
>     typedef unsigned short OutputPixelType;
>     typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>     typedef itk::CastImageFilter< ImageType, OutputImageType >    
> CastingFilterType;
>     typedef itkMeshTovtkPolyData::TriangleMeshType MeshType;
>     typedef itk::BinaryMask3DMeshSource< OutputImageType, MeshType > 
> MeshSourceType;
> 
>     typedef itk::CurvatureFlowImageFilter< ImageType, ImageType >  
> CurvatureFlowImageFilterType;
>     typedef itk::VTKPolyDataWriter<MeshType>   WriterType;
>     typedef itk::ConfidenceConnectedImageFilter<OutputImageType, 
> OutputImageType> ConnectedFilterType; /////COMENTAR P4
> 
>     MeshSourceType::Pointer meshSource = MeshSourceType::New();
>     CastingFilterType::Pointer caster = CastingFilterType::New();
>     CurvatureFlowImageFilterType::Pointer smoothing = 
> CurvatureFlowImageFilterType::New();
>     ConnectedFilterType::Pointer confidenceConnected = 
> ConnectedFilterType::New();/////COMENTAR P4
> 
> 
> 
>    ////// I have omitted the reading code  of  ITK
> 
> 
>     caster->SetInput(inputImage);   
>     caster->ReleaseDataFlagOn();
>     
>     confidenceConnected->SetInput( caster->GetOutput());  
>     confidenceConnected->SetMultiplier( 2.5 ); // confMultiplier
>     confidenceConnected->SetNumberOfIterations( 1 ); //confNumIterations
>     confidenceConnected->SetReplaceValue( 180 );  //confReplaceValue
>    
>     OutputImageType::IndexType  indexseed;
>     confidenceConnected->ClearSeeds();
> 
>     int semillaZ=(pVO->sizeZ()-valsemz);
>     indexseed[0] = valseedx;// x
>     indexseed[1] = valseedy;// y
>     indexseed[2] = valseedz;// z
>     confidenceConnected->SetSeed( indexseed );
>     confidenceConnected->SetInitialNeighborhoodRadius( 2 ); //confRadius
>     confidenceConnected->ReleaseDataFlagOn();
>     confidenceConnected->Update();
>    
>     OutputImageType::Pointer maskImage=confidenceConnected->GetOutput();
>    
>     ///here it is draw the planes (xz,yz) of the image limit
>     maskImage->Update();
>     meshSource->ReleaseDataFlagOn();   
>     meshSource->SetInput(maskImage);
>     meshSource->Update();
> 
>   ///here we convert to vtkpolydata
> 
>   vtkPolyData *vtkPolyDataOut = NULL;
> 
> 
>     itkMeshTovtkPolyData * itkMesh2PolyData = new itkMeshTovtkPolyData();
>     itkMesh2PolyData->SetInput (meshSource->GetOutput());
>     vtkPolyDataOut = itkMesh2PolyData->GetOutput();
>  
>     vtkCleanPolyData *pClean = vtkCleanPolyData::New();
>     pClean->SetInput(vtkPolyDataOut);
> 
>     vtkDecimatePro *pDecimador = vtkDecimatePro::New();
>     pDecimador->SetInput(pClean->GetOutput());
>     pDecimador->PreserveTopologyOn ();
>     pDecimador->SetTargetReduction(.30);
>    
>     vtkSmoothPolyDataFilter *pSmoother = vtkSmoothPolyDataFilter::New();
>     pSmoother->SetInput (pDecimador->GetOutput());
>     pSmoother->SetNumberOfIterations (3);
>     pSmoother->BoundarySmoothingOff ();
>     pSmoother->FeatureEdgeSmoothingOff ();
> 
>     vtkStripper * stripper = vtkStripper::New();
>     stripper->SetInput(pSmoother->GetOutput());
>     stripper->Update();
> 
>     vtkPolyData *pPolyData = stripper->GetOutput();
> 
>    //Here convert the vtkPolydata to my own type of visualization
>     triObject_t *obj = build3dObject (pPolyData, bInvertirCaras);
> 
> 
> greetings
> Manuel
> 
> 
> 
> ------------------------------------------------------------------------
> Discover the new Windows Vista Learn more! 
> <http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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