<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. &nbsp;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, &quot;Bernard Chiu&quot; &lt;<a href="bcychiu@alumni.uwo.ca">bcychiu@alumni.uwo.ca</a>&gt; 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-&gt;SetFileName((LPCSTR) inputfile);<BR>
<BR>
vtkImageFFT* fft = vtkImageFFT::New();<BR>
fft-&gt;SetInputConnection(vtkxmlreader-&gt;GetOutputPort());<BR>
<BR>
vtkXMLImageDataWriter* vtkxmlwriter = vtkXMLImageDataWriter::New();<BR>
vtkxmlwriter-&gt;SetInputConnection(fft-&gt;GetOutputPort());<BR>
vtkxmlwriter-&gt;SetFileName(&quot;C:\\testfft.vti&quot;);<BR>
vtkxmlwriter-&gt;Write();<BR>
<BR>
vtkxmlreader-&gt;Delete();<BR>
fft-&gt;Delete();<BR>
vtkxmlwriter-&gt;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-&gt;GetScalarPointerForExtent(outExt);<BR>
<BR>
This statement always return NULL, because vtkImageData::GetArrayPointer has an if-statement that does the following:<BR>
<BR>
  if (idx &lt; 0 || idx &gt; array-&gt;GetMaxId())<BR>
    {<BR>
    vtkErrorMacro(&quot;Coordinate (&quot; &lt;&lt; coordinate[0] &lt;&lt; &quot;, &quot; &lt;&lt; coordinate[1]<BR>
                  &lt;&lt; &quot;, &quot; &lt;&lt; coordinate[2] &lt;&lt; &quot;) out side of array (max = &quot;<BR>
                  &lt;&lt; array-&gt;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>
&nbsp;&nbsp;&nbsp;**** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kenneth Moreland<BR>
&nbsp;&nbsp;&nbsp;&nbsp;*** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sandia National Laboratories<BR>
*********** &nbsp;<BR>
*** *** *** &nbsp;email: <a href="kmorel@sandia.gov">kmorel@sandia.gov</a><BR>
** &nbsp;*** &nbsp;** &nbsp;phone: (505) 844-8919<BR>
&nbsp;&nbsp;&nbsp;&nbsp;*** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;web: &nbsp;&nbsp;<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>