[Insight-users] Help with conversion itk vtk

lolo lolailo l_o_lo at msn.com
Tue Jun 24 07:27:52 EDT 2008


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
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080624/53ce7bba/attachment-0001.htm>


More information about the Insight-users mailing list