Hi Miri,

you need to apply the geometry of your image to the surface so that both have 
the same origin. The code for doing that looks like the following:


    TimeSlicedGeometry::Pointer originalGeometry;

    AffineGeometryFrame3D::Pointer originalGeometryAGF = 
mitk_Image->GetTimeSlicedGeometry()->Clone();

    originalGeometry = dynamic_cast<TimeSlicedGeometry*>( 
originalGeometryAGF.GetPointer() );


    //Since the surface is no image geometry and hence should not be shifted 
for 0.5

    originalGeometry->ChangeImageGeometryConsideringOriginOffset(false);


    outputSurface->SetGeometry( originalGeometry );


Regards

Andreas

On 14.12.2011, at 16:30, Miri Trope wrote:

Hi All,

My algorithm has just generated a wonderful scalp extraction from T1 MRI image.
Now, I'm dealing with an irritating problem: that surface has been shifted as 
seen in the attachment.
How can I overcome that?

Flow chart of my conversions:
itk_Image => mitk_Image => vtk_Image => vtkPolyData

Snap code:

    //some manipulations on itk image
    mitk::CastToMitkImage(itk_Image, mitk_Image);

    vtkImageData* vtkImage = vtkImageData::New();
    vtk_Image = mitk_Image->GetVtkImageData();

    // smoothing
    vtkImageGaussianSmooth* smooth    = vtkImageGaussianSmooth::New();
    vtkImageMedian3D* med = vtkImageMedian3D::New();
    smooth->SetInput(vtkImage);
    med->SetInput(smooth->GetOutput());
    med->SetKernelSize(3,3,2);

    // conversion to vtk poly data
    vtkContourFilter* image2poly =    vtkContourFilter::New();
    image2poly->SetInput ( (vtkDataSet*)med->GetOutput());
    image2poly->SetValue(0,1);

    // pick the largest component
    vtkPolyDataConnectivityFilter* connectivity =    
vtkPolyDataConnectivityFilter::New();
    connectivity->ScalarConnectivityOff();
    connectivity->SetExtractionModeToLargestRegion();
    connectivity->SetInput(image2poly->GetOutput());

    // in order to view my output surface on mitk gui
    mitk::Surface::Pointer outputSurface::Surface::New();
    outputSurface->SetVtkPolyData(connectivity->GetOutput());
    outputSurface->Update();

    vtkPolyDataWriter* writerPD = vtkPolyDataWriter::New();
    writerPD->SetInput(connectivity->GetOutput());
    writerPD->SetFileName("Surface.vtk");
    writerPD->SetFileTypeToASCII();
    writerPD->Write();

<surface.JPG>------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits?
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users


------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity 
while improving strategic productivity.  Learn More! 
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to