[vtkusers] Announcement: New image rendering classes for VTK

Dženan Zukić dzenanz at gmail.com
Wed Jun 29 06:48:12 EDT 2011


Hi David,

with this I try to do what you suggested, i.e. consider VTK's world
coordinate system as DICOM patient coordinate system:

//red is the transformation-related code
void MainWindow::updateVisualization()
{
    typedef itk::ImageToVTKImageFilter<VisualizingImageType>
itkVtkConverter;
    itkVtkConverter::Pointer conv=itkVtkConverter::New();
    conv->SetInput(logic->visualizing);

    vtkGPUVolumeRayCastMapper *mapper = vtkGPUVolumeRayCastMapper::New();
    mapper->SetInput(conv->GetOutput());

    if (volume)
        volume->Delete();
    volume=vtkVolume::New();
    volume->SetProperty( myTransferFunction );
    volume->SetMapper( mapper );
    mapper->SetBlendModeToComposite();

    VisualizingImageType::DirectionType
d=logic->visualizing->GetDirection();
    vtkMatrix4x4 *mat=vtkMatrix4x4::New();
    for (int i=0; i<3; i++)
        for (int k=0; k<3; k++)
            mat->SetElement(i,k, d(i,k));
    mat->SetElement(3,3, 1);
    VisualizingImageType::SpacingType sp = logic->visualizing->GetSpacing();
    VisualizingImageType::PointType origin=logic->visualizing->GetOrigin();
    for (int i=0; i<3; i++)
        mat->SetElement(i,3, origin[i]/sp[i]);
    volume->SetUserMatrix(mat); //orientation and size OK, position wrong

    vtkRenderer *renderer =
vis->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
    renderer->RemoveAllViewProps();
    renderer->AddVolume( volume );
    defaultCameraPos(); //centers view on the volume, looking at it from
left
    vis->GetRenderWindow()->Render();

vis->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();
}

The polygonal data is in DICOM's patient coordinate system (vertex positions
from itk::Image->TransformIndexToPhysicalPoint() etc). The orientation is
correct, but I can't get the position correctly. I have tried
-origin[i]/sp[i], origin[i]*sp[i], origin[i], -origin[i], -2*origin[i] and
similar combinations but none of them worked. Any suggestion to what am I
doing wrong?

Regards,
Dženan

2011/6/29 David Gobbi <david.gobbi at gmail.com>

> On Tue, Jun 28, 2011 at 9:40 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
> > Hi David,
> >
> > I am interested in this too:
> > Does the above approach affect the polygonal actors in the scene
> (segmented
> > parts of the image)?
> > Regards,
> > Dženan
>
> When the DICOM patient coordinate system is used as the VTK world
> coordinate system, the assumption is that everything (images AND
> polydata) would have a either already be in the patient coordinate
> system, or if not, you would to have a 4x4 transform to set as the
> actor's UserMatrix (or UserTransform).  I.e. a transform to bring the
> data from its original coordinate system into the patient coordinate
> system.
>
>  - David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110629/702f0bee/attachment.htm>


More information about the vtkusers mailing list