[vtkusers] Is there a bug in vtkImageFFT?

Moreland, Kenneth kmorel at sandia.gov
Thu Apr 16 13:05:16 EDT 2009


Bernard,

As I am sure you have discovered, vtkImageFFT (and most of the imaging filters) uses the old convention of just grabbing the active scalars rather than letting you choose the array you want.  The easiest way this working is to use the vtkAssignAttribute filter, which allows you to assign one of the arrays as the active scalars.

-Ken


On 4/15/09 5:08 PM, "Bernard Chiu" <bcychiu at alumni.uwo.ca> wrote:

Hi,

I am trying to understand how vtkImageFFT works before using a similar method to process my image. I found that there is a run-time error. I wrote the following:

-----------------------------------------------------------------------------------------------------------
vtkXMLImageDataReader* vtkxmlreader = vtkXMLImageDataReader::New();
vtkxmlreader->SetFileName((LPCSTR) inputfile);

vtkImageFFT* fft = vtkImageFFT::New();
fft->SetInputConnection(vtkxmlreader->GetOutputPort());

vtkXMLImageDataWriter* vtkxmlwriter = vtkXMLImageDataWriter::New();
vtkxmlwriter->SetInputConnection(fft->GetOutputPort());
vtkxmlwriter->SetFileName("C:\\testfft.vti");
vtkxmlwriter->Write();

vtkxmlreader->Delete();
fft->Delete();
vtkxmlwriter->Delete();
--------------------------------------------------------------------------------------------------------------

I understand why the error occurred, but didn't know what is the best approach to make it work. I found that in the vtkImageFFT::ThreadedExecute method, there is a line

outPtr = outData->GetScalarPointerForExtent(outExt);

This statement always return NULL, because vtkImageData::GetArrayPointer has an if-statement that does the following:

  if (idx < 0 || idx > array->GetMaxId())
    {
    vtkErrorMacro("Coordinate (" << coordinate[0] << ", " << coordinate[1]
                  << ", " << coordinate[2] << ") out side of array (max = "
                  << array->GetMaxId());
    return NULL;
    }

Since the scalar array of the output image has not been initialized, MaxId is always -1 and NULL is always returned.

Run-time error therefore must occur at vtkImageFFT::vtkImageFFTExecute.

Could anyone tell me whether there is anything a user can do? I don't want to change the vtk code.

Thanks,
Bernard






   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090416/9c3f614c/attachment.htm>


More information about the vtkusers mailing list