[vtkusers] Extracting Slices using vtkImageReslice - Calculating extract spacing factor

Wagner Sales wsalles2003 at yahoo.com.br
Sat Apr 21 11:03:31 EDT 2007


Hi all,

I'm extracting slices from a DICOM dataset and writing on disk. The aproach are following:
- Load using vtkDICOMImageReader;
- Extract slices using vtkImageReslice.
- Write using vtkPNGImageWriter

-- CODE:
 m_Reslicer->SetInput(m_ImageData);

    m_Reslicer->SetInterpolationModeToLinear();

    double minSpacing = fabs(spacing[0]);

    if (fabs(spacing[1]) < minSpacing)

    {

    minSpacing = fabs(spacing[1]);

    }

    if (fabs(spacing[2]) < minSpacing)

    {

    minSpacing = fabs(spacing[2]);

    }

    m_Reslicer->SetOutputSpacing(minSpacing, minSpacing, minSpacing);

    m_Reslicer->GetOutput()->UpdateInformation();

    m_Reslicer->SetOutputDimensionality(2);

      m_Reslicer->SetResliceAxes(m_Matrix);

    m_Reslicer->GetOutput()->UpdateInformation();

    double point[4];

    double temp[4];

    point[0] = 0.0;

    point[1] = 0.0;

    switch(m_Axy)


    {


        case VolumeRepresentation::Coronal:


            point[2] = m_Reslicer->GetOutput()->GetSpacing()[0] * 0.5 // what's are the factor?;


              break;


        case VolumeRepresentation::Saggital:


            point[2] = m_Reslicer->GetOutput()->GetSpacing()[1] * 0.5 // what's are the factor?;


            break;


        case VolumeRepresentation::Transversal:


            point[2] = m_Reslicer->GetOutput()->GetSpacing()[2];


            break;


    }

    vtkMatrix4x4 *matrix = m_Reslicer->GetResliceAxes();

    point[3] = 1.0;

        matrix->MultiplyPoint(point, temp);

        matrix->SetElement(0, 3, temp[0]);

        matrix->SetElement(1, 3, temp[1]);

        matrix->SetElement(2, 3, temp[2]);

    m_Reslicer->Update();

    m_Slice->DeepCopy(m_Reslicer->GetOutput());

    return m_Slice;


When I extract slices from the transversal axis, all are extracted ok, but when I extract from coronal and sagittal axis, a lot of slices are empty. After some playing, I was discovered that's my error are these lines:

    point[2] = m_Reslicer->GetOutput()->GetSpacing()[];

Then I was multiplied, when extracting coronal or sagittal slices, like showed in the code.
Works fine! No empty slices anymore! But, the factor are fixed, and I don't know how to calculate the factor 0.5. 
I'm completely wrong? Someone can help?

Thks in advance,

Wagner Sales



   



__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070421/90b299f2/attachment.htm>


More information about the vtkusers mailing list