[vtkusers] vtkTensorGlyph

Charles Bassée charles.bassee at gmail.com
Mon Jul 28 07:39:28 EDT 2008


Hi everyone,

I'm trying to use vtkTensorGlyph to display a volume tensor field.
The data I have is a volumetric data containing for each voxel a
Tensor, which is a 3x3 symmetric definite positive matrix.

This Tensor Field is computed perviously to enhance tubular structures:

let say that the tensor should be very anisotropic (elongated along
the tube direction) and with high norm.

On the Background, the norm of the tensor is low.

I want to use vtkTensorGlyph to display this tensor field, and if it's
possible with transparency for tensors on the image background.


And my very first question is how to connect my inputs to vtkTensorGlyph.

For the moment, I'm doing it by writing a file like "tensors.vtk",
given in vtk data. It works fine, but without the transparency.

Can you please help me to make this connection directly without writing a file.

---------


First, the set of points is specified. Then a table of values for colors and
a table of tensors.

The provided data is a volumetric image of size : Nx, Ny, Nz.
The spacing is hx, hy, hz.
T is a double array of size Nx*Ny*Nz*9 : double T[Nx*Ny*Nz][9]. It contains
a symmetric definite matrix for each voxel (an anisotropic mertric).
double Scalars[Nx*Ny*Nz] is an array containing some norm of the tensor
field T (for example the sum of eigenvalues, or the max of eigenvalues, or
any other information). It gives the color for each tensor.

the first part of the code :

vtkPoints* points = vtkPoints::New();

float POS[3];



vtkFloatArray* scalars = vtkFloatArray::New();



vtkFloatArray* tensors = vtkFloatArray::New();



for(x = 0; x < Nx; x++)

   for(y = 0; y < Ny; y++)

      for(z = 0; z < Nz; z++){

         POS[0] = (x - (Nx-1)/2.0)*hx;

         POS[1] = (y - (Ny-1)/2.0)*hy;

         POS[2] = (z - (Nz-1)/2.0)*hz;

         points->InsertNextPoint(POS);

         point  = x + y*Nx + z*NxNy;

         scalars->InsertNextValue(Scalars[point]);

         tensors->InsertNextTuple9(T[point][0], T[point][1], T[point][2],

                                   T[point][3], T[point][4], T[point][5],

                                   T[point][6], T[point][7], T[point][8]

}



Then the vtkTensorGlyph and the geometry:



vtkSphereSource * sg1 = vtkSphereSource::New();

sg1->SetRadius(0.35);

sg1->SetCenter(0.0, 0.0, 0.0);



vtkTensorGlyph *g1 = vtkTensorGlyph::New();

g1->SetSource(sg1->GetOutput());




- My first problem is how can I connect the points, scalars and tensors to
the vtkTensorGlyph : g1.

Since the only example I have is :
/Graphics/Testing/Python/TestTensorGlyph.py
<http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Python/TestTensorGlyph.py?root=VTK&content-type=text/plain>

The data comes from the file 'tensors.vtk' which contains almost the same
informations.


So I have to convert [points, scalars, tensors] to a vtkAlgorithmOutput.

Then   g1->SetInputConnection()

Please, I need a help for this.


- The second point is that vtkTensorGlyph does not handle transparency.

Since values of scalars are very low on most voxels but has bigger values
along few tubular structures, It will be very useful to have transparency
with respect to scalars or to an other scalar table.


Thanks for your help.

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080728/27db8c22/attachment.htm>


More information about the vtkusers mailing list