[vtkusers] world coordinates and image data
Kall, Bruce A.
kall at mayo.edu
Thu Feb 26 10:19:15 EST 2009
> However, if you are looking to transform the data itself, your only
> option is to transform the imagedata to polys using
> vtkImageDataGeometryFilter and then transforming this using
> vtkTransformPolyDataFilter.
I have been able to accomplish what I think Richard original asked by using
vtkImageReslice *reslice;
I put the transform on this and it transforms all my image data which is
not axis aligned into world
coordinates correctly.
Small snippet:
-----------------------------------------------------------------------------------------------------------------------------
volume_reader = vtkImageReader::New();
volume_reader->SetFileName(data_filename);
volume_reader->SetFileDimensionality(3);
volume_reader->SetDataExtent(0,(int) xsize - 1,0,(int)ysize - 1,0,(int)
zsize - 1);
volume_reader->SetDataSpacing(voxel_size,voxel_size,voxel_size);
volume_reader->FileLowerLeftOn();
volume_reader->SetDataOrigin(origin);
volume_reader->SetDataScalarTypeToUnsignedChar();
volume_reader->SetDataByteOrderToBigEndian();
/* You may or may not need a permutation matrix here to have your volume
put in */
/* correctly. Mine starts at the upper left and not lower left */
permutation_xform = vtkTransform::New();
permutation_matrix = vtkMatrix4x4::New();
permutation_matrix->Identity();
permutation_matrix->SetElement(1,1,-1);
permutation_matrix->SetElement(2,2,-1);
permutation_xform->SetMatrix(permutation_matrix);
volume_reader->SetTransform(permutation_xform);
reslice_matrix = vtkMatrix4x4::New();
/* stuff in your transform here */
reslice_xform = vtkTransform::New();
reslice_xform->SetMatrix(reslice_matrix);
reslice = vtkImageReslice::New();
reslice->SetInputConnection(volume_reader->GetOutputPort());
reslice->SetResliceTransform(reslice_xform);
image_volume = vtkVolume::New();
volume_raycast_mapper = vtkFixedPointVolumeRayCastMapper::New();
volume_raycast_mapper->SetInputConnection(reslice->GetOutputPort());
image_volume->SetMapper(volume_raycast_mapper);
renderer->AddVolume(image_volume);
----------------------------------------------------------------------------------------------------------------------
This works for me.
Bruce
Karthik Krishnan wrote:
> On Wed, Feb 25, 2009 at 11:11 PM, Richard Beare
> <richard.beare at gmail.com <mailto:richard.beare at gmail.com>> wrote:
>
> Hi,
> I'm trying to track down appropriate vtk data representations for
> displaying multiple image data sets in correct relationships to one
> another. The source data is MRI slices.
>
> Does the vtkImageData type have the option of image axes not being
> aligned to world coordinates?
>
>
> no
>
>
> Assuming this isn't possible, what is the most appropriate data
> structure to use. The approach I'm thinking of is to iterate over the
> image in ITK, looking up world coordinates for each voxel, and
> building a large vtk data structure that I'd then save in a paraview
> compatible format.
>
>
> We tend to keep the image data in its local (axis aligned) coordinate
> system. You can manage local to world coordinate system mapping at the
> actor level by setting a user transform (see SetUserTransform) on the
> actor visualizing your data.
>
> However, if you are looking to transform the data itself, your only
> option is to transform the imagedata to polys using
> vtkImageDataGeometryFilter and then transforming this using
> vtkTransformPolyDataFilter.
>
>
>
> Any recommendations?
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
> --
> Karthik Krishnan
> R&D Engineer,
> Kitware Inc.
> Ph: 518 371 3971 x119
> Fax: 518 371 3971
> ------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090226/b007f223/attachment.htm>
More information about the vtkusers
mailing list