<html><body><div>Hi Bill,</div><div><br></div><div>The code below will illustrate the issue.</div><div><br></div><div>If you enable the color mapping code, by setting the #if 0 to #if 1, you will find that the color is a washed out white.</div><div><br></div><div>My desire is to have a ramp on a single hue, based on gray levels.</div><div><br></div><div>My data is typically from 0 - 0.69 which is what I set it to. The actual range is 0.0 &nbsp;- 1.0. but it pretty much never gets above</div><div>0.69.</div><div><br></div><div>I think the problem is perhaps not understanding the setup of the color table,,,but I'm unclear on how I should set it up other than</div><div>what I have.</div><div><br></div><div>The callback was used to interactively change the color table, but it wasn't helpful.</div><div><br></div><div>This is on Windows 7, using Visual Studio, and VTK 5.10.1</div><div><br></div><div>Thanks</div><div><br></div><div>Rick</div><div><br></div><div>----------------CODE---------------------------------------------------</div><div><div><br></div><div>#include &lt;vtkRenderer.h&gt;</div><div>#include &lt;vtkRenderWindow.h&gt;</div><div>#include &lt;vtkRenderWindowInteractor.h&gt;</div><div>#include &lt;vtkFloatArray.h&gt;</div><div>#include &lt;vtkImageMapper.h&gt;</div><div>#include &lt;vtkImageData.h&gt;</div><div>#include &lt;vtkPointData.h&gt;</div><div>#include &lt;vtkActor2D.h&gt;</div><div>#include &lt;vtkImageMapToColors.h&gt;</div><div>#include &lt;vtkLookupTable.h&gt;</div><div>#include &lt;vtkMinimalStandardRandomSequence.h&gt;</div><div>#include &lt;vtkInteractorStyle.h&gt;</div><div>#include "vtkInteractorStyleImage.h"</div><div>#include &lt;vtkCommand.h&gt;</div><div><br></div><div>#include &lt;vtkSmartPointer.h&gt;</div><div><br></div><div><br></div><div><br></div><div>class vtkImageInteractionCallback : public vtkCommand</div><div>{</div><div>public:</div><div><br></div><div>&nbsp; &nbsp; static vtkImageInteractionCallback *New()&nbsp;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return new vtkImageInteractionCallback;</div><div>&nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; vtkImageInteractionCallback()&nbsp;</div><div>&nbsp; &nbsp; {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;Interactor = 0;</div><div>&nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; void SetInteractor(vtkRenderWindowInteractor *interactor)&nbsp;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;Interactor = interactor;&nbsp;</div><div>&nbsp; &nbsp; };</div><div>&nbsp; &nbsp; vtkRenderWindowInteractor *GetInteractor()&nbsp;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return this-&gt;Interactor;</div><div>&nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; void SetColorTable(vtkLookupTable* colorTable)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; ColorTable = colorTable;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; virtual void Execute(vtkObject *, unsigned long event, void *)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindowInteractor *interactor = this-&gt;GetInteractor();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; int currPos[2];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; interactor-&gt;GetEventPosition(currPos);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (event == vtkCommand::LeftButtonPressEvent)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clickPos[0] = currPos[0];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clickPos[1] = currPos[1];</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if (event == vtkCommand::LeftButtonReleaseEvent)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if (event == vtkCommand::MouseWheelForwardEvent)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if (event == vtkCommand::MouseWheelBackwardEvent)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if (event == vtkCommand::MouseMoveEvent)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; interactor-&gt;GetInteractorStyle());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (style)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style-&gt;OnMouseMove();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; vtkRenderWindowInteractor *Interactor;</div><div>&nbsp; &nbsp; vtkLookupTable * ColorTable;</div><div>&nbsp; &nbsp; int clickPos[2];</div><div>};</div><div><br></div><div><br></div><div><br></div><div>int main (int argc, char *argv[])</div><div>{</div><div><br></div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderer&gt; aRenderer =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderer&gt;::New();</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderWindow&gt; renWin =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div><div>&nbsp; &nbsp; renWin-&gt;AddRenderer(aRenderer);</div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; iren =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</div><div>&nbsp; &nbsp; iren-&gt;SetRenderWindow(renWin);</div><div><br></div><div><br></div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkFloatArray&gt; floatData = vtkSmartPointer&lt;vtkFloatArray&gt;::New();</div><div><br></div><div>&nbsp; &nbsp; vtkIdType width = 500;</div><div>&nbsp; &nbsp; vtkIdType height = 500;</div><div><br></div><div><br></div><div><br></div><div>&nbsp; &nbsp; vtkIdType nt = width * height;</div><div>&nbsp; &nbsp; floatData-&gt;SetNumberOfTuples(nt);</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkMinimalStandardRandomSequence&gt; rg = vtkSmartPointer&lt;vtkMinimalStandardRandomSequence&gt;::New();</div><div><br></div><div>&nbsp; &nbsp; for(vtkIdType i = 0; i &lt; nt; i++)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; float rn = rg-&gt;GetRangeValue(0,0.69);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; rg-&gt;Next();</div><div>&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; floatData-&gt;SetTuple(i,&amp;rn);</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkImageData&gt; image = vtkSmartPointer&lt;vtkImageData&gt;::New();</div><div>&nbsp; &nbsp; image-&gt;SetExtent(0,width-1,0,height-1,0,0);</div><div>&nbsp; &nbsp; image-&gt;SetNumberOfScalarComponents(1);</div><div>&nbsp; &nbsp; image-&gt;SetScalarTypeToFloat();</div><div>&nbsp; &nbsp; image-&gt;SetSpacing(0.1,0.1,1.0);</div><div><br></div><div>&nbsp; &nbsp; image-&gt;GetPointData()-&gt;SetScalars(floatData);</div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkImageMapper&gt; mapper = &nbsp;vtkSmartPointer&lt;vtkImageMapper&gt;::New();</div><div><br></div><div>&nbsp; &nbsp; mapper-&gt;SetInputConnection(image-&gt;GetProducerPort());</div><div>&nbsp; &nbsp; mapper-&gt;SetColorWindow(1.0);</div><div>&nbsp; &nbsp; mapper-&gt;SetColorLevel(0.5);</div><div><br></div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkActor2D&gt; actor = vtkSmartPointer&lt;vtkActor2D&gt;::New();</div><div>&nbsp; &nbsp; actor-&gt;SetPosition(0,0);</div><div><br></div><div>&nbsp; &nbsp; actor-&gt;SetMapper(mapper);</div><div><br></div><div>&nbsp; &nbsp; aRenderer-&gt;AddActor(actor);</div><div><br></div><div>&nbsp; &nbsp; // turn this on to map to colors.</div><div>#if 0</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkImageInteractionCallback&gt; callback = vtkSmartPointer&lt;vtkImageInteractionCallback&gt;::New();</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkInteractorStyleImage&gt; imageStyle = vtkSmartPointer&lt;vtkInteractorStyleImage&gt;::New();</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; iren-&gt;SetInteractorStyle(imageStyle);</div><div>&nbsp; &nbsp; callback-&gt;SetInteractor(iren);</div><div>&nbsp; &nbsp; renWin-&gt;SetInteractor(iren);</div><div>&nbsp; &nbsp; imageStyle-&gt;AddObserver(vtkCommand::MouseMoveEvent, callback);</div><div>&nbsp; &nbsp; imageStyle-&gt;AddObserver(vtkCommand::LeftButtonPressEvent, callback);</div><div>&nbsp; &nbsp; imageStyle-&gt;AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);</div><div>&nbsp; &nbsp; &nbsp;imageStyle-&gt;AddObserver(vtkCommand::MouseWheelForwardEvent, callback);</div><div><br></div><div>&nbsp; &nbsp; imageStyle-&gt;AddObserver(vtkCommand::MouseWheelBackwardEvent, callback);</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkImageMapToColors&gt; filter = vtkSmartPointer&lt;vtkImageMapToColors&gt;::New();</div><div>&nbsp; &nbsp; vtkSmartPointer&lt;vtkLookupTable&gt; colorTable = vtkSmartPointer&lt;vtkLookupTable&gt;::New();</div><div>&nbsp; &nbsp; callback-&gt;SetColorTable(colorTable);</div><div>&nbsp; &nbsp; filter-&gt;SetOutputFormatToRGBA();</div><div>&nbsp; &nbsp; colorTable-&gt;SetTableRange(0,1);&nbsp;</div><div><br></div><div><br></div><div>&nbsp; &nbsp; colorTable-&gt;SetHueRange(0.3,0.3);</div><div>&nbsp; &nbsp; colorTable-&gt;SetSaturationRange(0,1);</div><div>&nbsp; &nbsp; colorTable-&gt;SetValueRange(1,1);</div><div>&nbsp; &nbsp; colorTable-&gt;SetRampToLinear();</div><div>&nbsp; &nbsp; colorTable-&gt;ForceBuild();</div><div>&nbsp; &nbsp; filter-&gt;SetLookupTable(colorTable);</div><div>&nbsp; &nbsp; filter-&gt;SetNumberOfThreads(1);</div><div><br></div><div>&nbsp; &nbsp; filter-&gt;SetInputConnection(image-&gt;GetProducerPort());</div><div>&nbsp; &nbsp; mapper-&gt;SetInputConnection(filter-&gt;GetOutputPort());</div><div>#endif</div><div><br></div><div><br></div><div>&nbsp; &nbsp; aRenderer-&gt;SetBackground(.2, .3, .4);</div><div>&nbsp; &nbsp; renWin-&gt;SetSize(640, 480);</div><div><br></div><div><br></div><div><br></div><div>&nbsp; &nbsp; // Initialize the event loop and then start it.</div><div>&nbsp; &nbsp; iren-&gt;Initialize();</div><div>&nbsp; &nbsp; iren-&gt;Start();</div><div><br></div><div>&nbsp; &nbsp; return EXIT_SUCCESS;</div><div>}</div><div><br></div><br>On Jul 19, 2013, at 09:32 PM, Bill Lorensen &lt;bill.lorensen@gmail.com&gt; wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote"><div dir="ltr">Can you post a small, compilable example that illustrates the problem?<div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 19, 2013 at 9:20 PM, Rick Frank <span dir="ltr">&lt;<a href="mailto:rickfrank@me.com" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br> Hi,<br> <br> I'm getting some behavior I don't understand when trying to map gray floating point image to a color image<br> <br> What I'm seeing is that the output is completely white.<br> <br> my code is roughly as follows<br> <br> filter-&gt;SetOutputFormatToRGBA()<br> <br> colorTable-&gt;SetTableRange(0,1)<br> colorTable-&gt;SetHueRange(0,1);<br> colorTable-&gt;SetSaturationRange(0,1);<br> colorTable-&gt;SetValueRange(0,1);<br> colorTable-&gt;SetRampToLinear();<br> <br> colorTable-&gt;ForceBuild();<br> <br> Now, when I trace through the code, the values set in the RGBA image look correct. But the ultimate rendered image is completely white.<br> <br> If I modify the code so that all the RGBA values are 1,0,0,255 the image is solid red. If I change the alpha to 64 nothing changes.<br> <br> So, I suspect it's the mapper - I use the same mapper - vtkImageMapper to display the color image by resetting the input connection:<br> <br> mapper-&gt;SetInputConnection(filter-&gt;GetOutputPort());<br> imageActor-&gt;SetMapper(mapper);<br> <br> Do I need to make a change to the mapper to get the proper RGBA display?<br> <br> <br> Thanks<br> <br> Rick<br> <br> _______________________________________________<br> Powered by <a href="http://www.kitware.com" data-mce-href="http://www.kitware.com">www.kitware.com</a><br> <br> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br> <br> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" data-mce-href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br> <br> Follow this link to subscribe/unsubscribe:<br> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" data-mce-href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br><br><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br></div></div></blockquote></div></body></html>