<HTML>
<HEAD>
<TITLE>Re: [vtkusers] Is there a bug in vtkImageFFT?</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Bernard,<BR>
<BR>
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.<BR>
<BR>
-Ken<BR>
<BR>
<BR>
On 4/15/09 5:08 PM, "Bernard Chiu" <<a href="bcychiu@alumni.uwo.ca">bcychiu@alumni.uwo.ca</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi,<BR>
<BR>
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:<BR>
<BR>
-----------------------------------------------------------------------------------------------------------<BR>
vtkXMLImageDataReader* vtkxmlreader = vtkXMLImageDataReader::New();<BR>
vtkxmlreader->SetFileName((LPCSTR) inputfile);<BR>
<BR>
vtkImageFFT* fft = vtkImageFFT::New();<BR>
fft->SetInputConnection(vtkxmlreader->GetOutputPort());<BR>
<BR>
vtkXMLImageDataWriter* vtkxmlwriter = vtkXMLImageDataWriter::New();<BR>
vtkxmlwriter->SetInputConnection(fft->GetOutputPort());<BR>
vtkxmlwriter->SetFileName("C:\\testfft.vti");<BR>
vtkxmlwriter->Write();<BR>
<BR>
vtkxmlreader->Delete();<BR>
fft->Delete();<BR>
vtkxmlwriter->Delete();<BR>
--------------------------------------------------------------------------------------------------------------<BR>
<BR>
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<BR>
<BR>
outPtr = outData->GetScalarPointerForExtent(outExt);<BR>
<BR>
This statement always return NULL, because vtkImageData::GetArrayPointer has an if-statement that does the following:<BR>
<BR>
if (idx < 0 || idx > array->GetMaxId())<BR>
{<BR>
vtkErrorMacro("Coordinate (" << coordinate[0] << ", " << coordinate[1]<BR>
<< ", " << coordinate[2] << ") out side of array (max = "<BR>
<< array->GetMaxId());<BR>
return NULL;<BR>
}<BR>
<BR>
Since the scalar array of the output image has not been initialized, MaxId is always -1 and NULL is always returned.<BR>
<BR>
Run-time error therefore must occur at vtkImageFFT::vtkImageFFTExecute.<BR>
<BR>
Could anyone tell me whether there is anything a user can do? I don't want to change the vtk code.<BR>
<BR>
Thanks,<BR>
Bernard<BR>
<BR>
<BR>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="1"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:7.5pt'><BR>
**** Kenneth Moreland<BR>
*** Sandia National Laboratories<BR>
*********** <BR>
*** *** *** email: <a href="kmorel@sandia.gov">kmorel@sandia.gov</a><BR>
** *** ** phone: (505) 844-8919<BR>
*** web: <a href="http://www.cs.unm.edu/~kmorel">http://www.cs.unm.edu/~kmorel</a><BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>