<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 - 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 <vtkRenderer.h></div><div>#include <vtkRenderWindow.h></div><div>#include <vtkRenderWindowInteractor.h></div><div>#include <vtkFloatArray.h></div><div>#include <vtkImageMapper.h></div><div>#include <vtkImageData.h></div><div>#include <vtkPointData.h></div><div>#include <vtkActor2D.h></div><div>#include <vtkImageMapToColors.h></div><div>#include <vtkLookupTable.h></div><div>#include <vtkMinimalStandardRandomSequence.h></div><div>#include <vtkInteractorStyle.h></div><div>#include "vtkInteractorStyleImage.h"</div><div>#include <vtkCommand.h></div><div><br></div><div>#include <vtkSmartPointer.h></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> static vtkImageInteractionCallback *New() </div><div> {</div><div> return new vtkImageInteractionCallback;</div><div> };</div><div><br></div><div> vtkImageInteractionCallback() </div><div> {</div><div><br></div><div> this->Interactor = 0;</div><div> };</div><div><br></div><div> void SetInteractor(vtkRenderWindowInteractor *interactor) </div><div> {</div><div> this->Interactor = interactor; </div><div> };</div><div> vtkRenderWindowInteractor *GetInteractor() </div><div> {</div><div> return this->Interactor;</div><div> };</div><div><br></div><div> void SetColorTable(vtkLookupTable* colorTable)</div><div> {</div><div> ColorTable = colorTable;</div><div> }</div><div> virtual void Execute(vtkObject *, unsigned long event, void *)</div><div> {</div><div> vtkRenderWindowInteractor *interactor = this->GetInteractor();</div><div><br></div><div> </div><div> int currPos[2];</div><div> interactor->GetEventPosition(currPos);</div><div><br></div><div> if (event == vtkCommand::LeftButtonPressEvent)</div><div> {</div><div> clickPos[0] = currPos[0];</div><div> clickPos[1] = currPos[1];</div><div><br></div><div> }</div><div> else if (event == vtkCommand::LeftButtonReleaseEvent)</div><div> {</div><div><br></div><div> }</div><div><br></div><div> else if (event == vtkCommand::MouseWheelForwardEvent)</div><div> {</div><div> </div><div> }</div><div> else if (event == vtkCommand::MouseWheelBackwardEvent)</div><div> {</div><div> </div><div> </div><div> }</div><div><br></div><div> else if (event == vtkCommand::MouseMoveEvent)</div><div> {</div><div><br></div><div> }</div><div> else</div><div> {</div><div> vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(</div><div> interactor->GetInteractorStyle());</div><div> if (style)</div><div> {</div><div> style->OnMouseMove();</div><div> }</div><div> }</div><div> }</div><div><br></div><div> vtkRenderWindowInteractor *Interactor;</div><div> vtkLookupTable * ColorTable;</div><div> 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> vtkSmartPointer<vtkRenderer> aRenderer =</div><div> vtkSmartPointer<vtkRenderer>::New();</div><div> vtkSmartPointer<vtkRenderWindow> renWin =</div><div> vtkSmartPointer<vtkRenderWindow>::New();</div><div> renWin->AddRenderer(aRenderer);</div><div><br></div><div> vtkSmartPointer<vtkRenderWindowInteractor> iren =</div><div> vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> iren->SetRenderWindow(renWin);</div><div><br></div><div><br></div><div><br></div><div> vtkSmartPointer<vtkFloatArray> floatData = vtkSmartPointer<vtkFloatArray>::New();</div><div><br></div><div> vtkIdType width = 500;</div><div> vtkIdType height = 500;</div><div><br></div><div><br></div><div><br></div><div> vtkIdType nt = width * height;</div><div> floatData->SetNumberOfTuples(nt);</div><div> vtkSmartPointer<vtkMinimalStandardRandomSequence> rg = vtkSmartPointer<vtkMinimalStandardRandomSequence>::New();</div><div><br></div><div> for(vtkIdType i = 0; i < nt; i++)</div><div> {</div><div> float rn = rg->GetRangeValue(0,0.69);</div><div> rg->Next();</div><div> </div><div> floatData->SetTuple(i,&rn);</div><div> }</div><div><br></div><div> vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();</div><div> image->SetExtent(0,width-1,0,height-1,0,0);</div><div> image->SetNumberOfScalarComponents(1);</div><div> image->SetScalarTypeToFloat();</div><div> image->SetSpacing(0.1,0.1,1.0);</div><div><br></div><div> image->GetPointData()->SetScalars(floatData);</div><div><br></div><div> vtkSmartPointer<vtkImageMapper> mapper = vtkSmartPointer<vtkImageMapper>::New();</div><div><br></div><div> mapper->SetInputConnection(image->GetProducerPort());</div><div> mapper->SetColorWindow(1.0);</div><div> mapper->SetColorLevel(0.5);</div><div><br></div><div> vtkSmartPointer<vtkActor2D> actor = vtkSmartPointer<vtkActor2D>::New();</div><div> actor->SetPosition(0,0);</div><div><br></div><div> actor->SetMapper(mapper);</div><div><br></div><div> aRenderer->AddActor(actor);</div><div><br></div><div> // turn this on to map to colors.</div><div>#if 0</div><div> vtkSmartPointer<vtkImageInteractionCallback> callback = vtkSmartPointer<vtkImageInteractionCallback>::New();</div><div> vtkSmartPointer<vtkInteractorStyleImage> imageStyle = vtkSmartPointer<vtkInteractorStyleImage>::New();</div><div> </div><div> iren->SetInteractorStyle(imageStyle);</div><div> callback->SetInteractor(iren);</div><div> renWin->SetInteractor(iren);</div><div> imageStyle->AddObserver(vtkCommand::MouseMoveEvent, callback);</div><div> imageStyle->AddObserver(vtkCommand::LeftButtonPressEvent, callback);</div><div> imageStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, callback);</div><div> imageStyle->AddObserver(vtkCommand::MouseWheelForwardEvent, callback);</div><div><br></div><div> imageStyle->AddObserver(vtkCommand::MouseWheelBackwardEvent, callback);</div><div> vtkSmartPointer<vtkImageMapToColors> filter = vtkSmartPointer<vtkImageMapToColors>::New();</div><div> vtkSmartPointer<vtkLookupTable> colorTable = vtkSmartPointer<vtkLookupTable>::New();</div><div> callback->SetColorTable(colorTable);</div><div> filter->SetOutputFormatToRGBA();</div><div> colorTable->SetTableRange(0,1); </div><div><br></div><div><br></div><div> colorTable->SetHueRange(0.3,0.3);</div><div> colorTable->SetSaturationRange(0,1);</div><div> colorTable->SetValueRange(1,1);</div><div> colorTable->SetRampToLinear();</div><div> colorTable->ForceBuild();</div><div> filter->SetLookupTable(colorTable);</div><div> filter->SetNumberOfThreads(1);</div><div><br></div><div> filter->SetInputConnection(image->GetProducerPort());</div><div> mapper->SetInputConnection(filter->GetOutputPort());</div><div>#endif</div><div><br></div><div><br></div><div> aRenderer->SetBackground(.2, .3, .4);</div><div> renWin->SetSize(640, 480);</div><div><br></div><div><br></div><div><br></div><div> // Initialize the event loop and then start it.</div><div> iren->Initialize();</div><div> iren->Start();</div><div><br></div><div> return EXIT_SUCCESS;</div><div>}</div><div><br></div><br>On Jul 19, 2013, at 09:32 PM, Bill Lorensen <bill.lorensen@gmail.com> 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"><<a href="mailto:rickfrank@me.com" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>></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->SetOutputFormatToRGBA()<br> <br> colorTable->SetTableRange(0,1)<br> colorTable->SetHueRange(0,1);<br> colorTable->SetSaturationRange(0,1);<br> colorTable->SetValueRange(0,1);<br> colorTable->SetRampToLinear();<br> <br> colorTable->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->SetInputConnection(filter->GetOutputPort());<br> imageActor->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>