[vtkusers] how to write an image filter that produces tensors

Alexandre Guimond guimond at bwh.harvard.edu
Fri Jun 22 10:35:10 EDT 2001


Hi all.

I want to write a filter that take an image as input an outputs an
image with a 3x3 tensor associated with each voxel of the input image,
ie output voxels are 9D (or 6D in my case since my tensors are
symmetric).

I'm presenlty using a vtkImageToImageFilter as a base class for this
process.

Since scalars can have at most 4D, I was thinking of getting rid of
the scalar field and adding a tensor field in the ExecuteInformation
of my filter, ie:

void vtkStuff::ExecuteInformation(vtkImageData *inData,
                        	  vtkImageData *outData)
{
  int* dims=inData->GetDimensions();
  
  vtkTensors* tensors=vtkTensors::New();
  tensors->SetDataType(inData->GetScalarType());
  tensors->SetNumberOfTensors(dims[0]*dims[1]*dims[2]);

  outData->GetPointData()->SetTensors(tensors);
  outData->GetPointData()->SetScalars((vtkScalars*)0);
  
  tensors->Delete();
}

This doesn't seem to work.  I guess that between this call and the
call to ThreadedExecute, my output is reformated: the scalar data is
back and the tensor data doesn't exist anymore.

So I guess I have to create the tensor data pretty close to the
ThreadedExecute call.  Probably in the ExecuteData call, but it just
doesn't feel right since this is the execution part, not the
formatting part... yes?

Hence the questions: 

- does everything I just wrote sound ok?
- Can anyone confirm that a filter that produces tensors from an image
should create these tensors in vtkStuff::ExecuteData?

many thx for your input,
-- 
Alexandre Guimond, Ph.D. guimond at bwh.harvard.edu Phone:(617) 278-0800 
http://spl.bwh.harvard.edu:8000/~guimond/          Fax:(617) 264-5154
Brigham and Women's Hospital, Harvard Medical School
CNI, RF396, 221 Longwood Av, Boston, MA 02115




More information about the vtkusers mailing list