<DIV id=RTEContent>Hi everyone, </DIV> <DIV> </DIV> <DIV>I am triing to display my image data of range [-2, +2] with a colormap. </DIV> <DIV> </DIV> <DIV>I took a look on <STRONG>vtkLookupTable</STRONG> and <STRONG>vtkImageMapToColors</STRONG> but it seems that I didn't catch vtkLookupTable notion: my displayed image is all green!!!!!</DIV> <DIV> </DIV> <DIV>Here is what I did:</DIV> <DIV> </DIV> <DIV><FONT size=2> <div><STRONG><EM>vtkImageReader* reader = vtkImageReader::New();</EM></STRONG></div> <div><STRONG><EM>reader->SetFileDimensionality(3); </EM></STRONG></FONT><FONT color=#008000 size=2><STRONG><EM>//all the slices are in one file </EM></STRONG></div></FONT><FONT size=2> <div><STRONG><EM>reader->SetFileName("filename.raw");</EM></STRONG></div> <div><STRONG><EM>reader->SetNumberOfScalarComponents(1); </EM></STRONG></FONT><FONT color=#008000 size=2><STRONG><EM>//image is greyscale </EM></STRONG></div></FONT><FONT size=2>
<div><STRONG><EM>reader->SetDataScalarTypeToFloat(); </EM></STRONG></FONT><FONT color=#008000 size=2><STRONG><EM>//4 byte</EM></STRONG></div></FONT><FONT size=2> <div><STRONG><EM>reader->SetDataExtent(0,193, 0,54, 0,164); </EM></STRONG></FONT><FONT color=#008000 size=2><STRONG><EM>//194 x 55 x 165 </EM></STRONG></div></FONT><FONT size=2> <div><STRONG><EM>reader->SetDataSpacing(1.0, 194/55, 1.0);</EM></STRONG></div> <div><STRONG><EM>reader->SetDataOrigin(0.0, 0.0, 0.0);</EM></STRONG></div> <div><STRONG><EM>reader->UpdateWholeExtent();</EM></STRONG></div> <div><STRONG><EM></EM></STRONG></FONT><FONT color=#008000 size=2></FONT> </div> <div><FONT color=#008000 size=2><STRONG><EM>//rescaling in [0-255]</EM></STRONG></div></FONT> <div><FONT size=2><STRONG><EM>vtkImageShiftScale* shiftScale = vtkImageShiftScale::New();</EM></STRONG></div> <div><STRONG><EM>shiftScale->SetInputConnection(reader->GetOutputPort());</EM></STRONG></div> <div></FONT><FONT
size=2><STRONG><EM>shiftScale->SetOutputScalarTypeToUnsignedChar();</EM></STRONG></div> <div><STRONG><EM></EM></STRONG> </div> <div><FONT color=#0000ff size=2><STRONG><EM>float</EM></STRONG></FONT><FONT size=2><STRONG><EM> min = reader->GetOutput()->GetScalarRange()[0];</EM></STRONG></div> <div></FONT><FONT color=#0000ff size=2><STRONG><EM>float</EM></STRONG></FONT><FONT size=2><STRONG><EM> max = reader->GetOutput()->GetScalarRange()[1];</EM></STRONG></div> <div></FONT></FONT><FONT size=2><STRONG><EM>vtkLookupTable* table = vtkLookupTable::New();</EM></STRONG></div></DIV> <DIV> <div><STRONG><EM>table->SetTableRange(min,max);</EM></STRONG></div> <div><STRONG><EM>table->SetHueRange(0.0, 0.667);</EM></STRONG></FONT><FONT color=#008000 size=2><STRONG><EM>//red to blue </EM></STRONG></div></FONT><FONT size=2> <div><STRONG><EM>table->SetSaturationRange(1.0, 1.0);</EM></STRONG></div> <div><STRONG><EM>table->SetValueRange(1.0,
1.0);</EM></STRONG></div> <div><STRONG><EM>table->SetAlphaRange (1.0, 1.0);</EM></STRONG></div> <div><STRONG><EM>table->SetNumberOfColors(256);</EM></STRONG></div> <div><STRONG><EM>table->Build();</EM></STRONG></div> <div><STRONG><EM></EM></STRONG> </div> <div></FONT><FONT color=#008000 size=2><STRONG><EM>//convert to color:</EM></STRONG></div></FONT><FONT size=2> <div><STRONG><EM>vtkImageMapToColors* colormap = vtkImageMapToColors::New();</EM></STRONG></div> <div><STRONG><EM>colormap->SetInput(shiftScale->GetOutput());</EM></STRONG></div> <div><STRONG><EM>colormap->SetLookupTable(table);</EM></STRONG></div> <div><STRONG><EM>colormap->SetOutputFormatToRGB();</EM></STRONG></div> <div><STRONG><EM></EM></STRONG> </div> <div><STRONG><EM></EM></STRONG></div> <div><STRONG><EM>vtkImageViewer2* viewer = vtkImageViewer2::New();</EM></STRONG></div> <div><STRONG><EM>viewer->SetInput(colormap->GetOutput());</EM></STRONG></div>
<div><STRONG><EM>colormap->Delete();</EM></STRONG></div> <div><STRONG><EM>reader->Delete();</EM></STRONG></div> <div><STRONG><EM></EM></STRONG> </div></FONT><FONT size=2> <div><STRONG><EM>viewer->SetSlice(10);</EM></STRONG></FONT><FONT size=2> <div><STRONG><EM></EM></STRONG></div><STRONG><EM>viewer->Render();</EM></STRONG></div></FONT></DIV> <DIV> </DIV> <DIV>Please help me. It is pretty quite urgent. </DIV> <DIV> </DIV> <DIV>Isabelle</DIV><p>
                <hr size=1> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta.