<div class="gmail_quote">On Thu, Feb 11, 2010 at 11:33 AM, Christian Werner <span dir="ltr">&lt;<a href="mailto:christian.werner@rwth-aachen.de">christian.werner@rwth-aachen.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello!<br>
<br>
I used the vtkSimpleImageToImageFilter to make a nifty little segmentation to get started. Below is how I overwrote the SimpleExecute function. It looks good and actually does the job, at least in a Reader&gt;MyFilter&gt;Writer setup. But if its passed to a vtkTexturePainter I get a warning that comes from the function<br>

<br>
int vtkTexturePainter::SetupScalars(vtkImageData* input) ...<br>
<br>
Warning: In /opt/ParaView3/Servers/Filters/vtkTexturePainter.cxx, line 173<br>
vtkTexturePainter (0x1a34fd0): Failed to locate selected scalars. Will use image scalars by default.<br>
<br>
<br>
What is displayed then (this is all with Paraview by the way) is an image which is indeed segmented as meant, but it has strange colors. The background color of the image mysteriously gets the background color of the 2d viewer (but should be 0/black), and the foreground color (which should be white) is some ugly pink, or green, now that I tried again. Also Paraview does not seem to have information about the data array, at least its not listed where as there IS information on the original image: DataType: unsigned char, Data Ranges[0,255]...<br>

<br>
<br>
Here is my code:<br>
<br>
<br>
void vtkDislev::SimpleExecute(vtkImageData* input, vtkImageData* output)<br>
{<br>
   if (input==NULL) {<br>
   vtkErrorMacro(&lt;&lt;&quot;Bad Input to vtkDislev&quot;);<br>
   return;<br>
   }<br>
     int dim[3];<br>
   input-&gt;GetDimensions(dim);<br>
   int numvox  = dim[0]*dim[1]*dim[2];<br>
   int numcomp = input-&gt;GetNumberOfScalarComponents();<br>
     vtkDataArray* inarray  = input-&gt;GetPointData()-&gt;GetScalars();<br>
   vtkDataArray* outarray = output-&gt;GetPointData()-&gt;GetScalars();<br>
     unsigned char in=255;<br>
   unsigned char out=0;<br>
   for (int component=0; component &lt; numcomp; component++) {<br>
   for (int i=0; i &lt; numvox; i++) {<br>
       unsigned char v=inarray-&gt;GetComponent(i,component);<br>
       if (v &gt;= this-&gt;LowerThreshold &amp;&amp; v&lt;=this-&gt;UpperThreshold) {<br>
       outarray-&gt;SetComponent(i,component,in);<br>
       } else {<br>
       outarray-&gt;SetComponent(i,component,out);              }<br>
   }<br>
   }<br>
}<br>
<br>
<br>
Anyone any idea?<br>
<br>
Best regards,<br>
Christian<br>
__<br><br></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">It looks like this (from vtkTexturePainter.cxx) is returning NULL:</div><div class="gmail_quote"><br></div><div class="gmail_quote">  vtkDataArray* scalars = vtkAbstractMapper::GetScalars(input,</div>
<div class="gmail_quote">    this-&gt;ScalarMode, </div><div class="gmail_quote">    this-&gt;ScalarArrayName? VTK_GET_ARRAY_BY_NAME : VTK_GET_ARRAY_BY_ID,</div><div class="gmail_quote">    this-&gt;ScalarArrayIndex,</div>
<div class="gmail_quote">    this-&gt;ScalarArrayName,</div><div class="gmail_quote">    cellFlag);</div><div class="gmail_quote"><br></div><div class="gmail_quote">It looks like you can call</div><div class="gmail_quote">
painter-&gt;SetScalarArrayName(&quot;yourArray&quot;);</div><div class="gmail_quote"><br></div><div class="gmail_quote">to set the array that you want it to use.</div><div class="gmail_quote"><br></div><div class="gmail_quote">
Hope that helps,</div><br>David</div>