You need to set a lookup table on the
vtkImageMapToWIndowLevelColors (viewer->GetWindowLevel()) to get
colors to show up.<br><br> // Something like the following should do... <br> imageviewer2->GetWindowLevel()->SetOutputFormatToRGB();<br> vtkLookupTable *lut = vtkLookupTable::New();<br> lut->SetHueRange(0.66667, 0.0);<br>
lut->SetSaturationRange(1, 1);<br> lut->SetValueRange(1, 1);<br> lut->SetAlphaRange(1, 1);<br> lut->SetNumberOfColors(256);<br> lut->Build();<br> imageviweer2->GetWindowLevel()->SetLookupTable(lut);<br>
<br>-----<br>Or a hack to avoid settting the lookup table is... <br><br> this->ImageViewer[0]->SetColorLevel(127.50001); // minor offset from 127.5<br><br>If you dig into the sources, you'll find out why the hack works :)<br>
<br><br>bye<br>--<br>karthik<br><br><br>
<br>Can you offset the level a bit and test it as:<br><span class="q"> viewer->GetWindowLevel()->SetLevel( 127.501 );</span><br><br>Or else, you need to set a lookup table on the vtkImageMapToWIndowLevelColors (viewer->GetWindowLevel()) to get colors to show up.<br>
<br><br><div><span class="gmail_quote">On 3/5/08, <b class="gmail_sendername">Elvis Chen</b> <<a href="mailto:elvis.chen@gmail.com">elvis.chen@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hi David,<br><br>Thanks for the quick reply. I've put the following 3 lines into my code:<span class="q"><br><br><br> viewer->GetWindowLevel()->SetWindow( 255.0 );<br> viewer->GetWindowLevel()->SetLevel( 127.5 );<br>
</span> viewer->GetWindowLevel()->SetLookupTable( 0 );<br>
<br>(your 1st email was sent to me only, not to vtkusers), but I still only get black/white image. Actually, the line that nulls the lookup table doesn't change the grabbed image at all. Should I not use vtkImageViewer2 at all?<br>
<br>h.imageRGB is an int array created using "new int [ 720x480x3 ]". What data scalar type should I set it to?<br><span class="sg"><br>Elvis</span><div><span class="e" id="q_118809c641213ea8_4"><br><br><br><div class="gmail_quote">
On Wed, Mar 5, 2008 at 3:07 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.gobbi@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">And you might also have to set the following:<br>
<br>
viewer->GetWindowLevel()->SetWindow(255.0);<br>
viewer->GetWindowLevel()->SetLevel(127.5);<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div><br>
<br>
<br>
On Wed, Mar 5, 2008 at 3:04 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.gobbi@gmail.com</a>> wrote:<br>
> Hi Elvis,<br>
><br>
> I looked at the vtkImageViewer2 code, and it creates a default color<br>
> table for you. If you get rid of its color table, it should display the RGB<br>
> data directly.<br>
><br>
> The command to get rid of the viewer's color table is as follows:<br>
><br>
> viewer->GetWindowLevel()->SetLookupTable(0);<br>
><br>
> David<br>
><br>
><br>
><br>
><br>
> On Wed, Mar 5, 2008 at 2:48 PM, Elvis Chen <<a href="mailto:elvis.chen@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">elvis.chen@gmail.com</a>> wrote:<br>
> > hello,<br>
> ><br>
> > I'm trying to import video/still-images from an ultra-sound machine and<br>
> > display it using vtk. I can grab an image from the frame-grabber and save<br>
> > the image as PPM (basically RGB values with some headers). The range of the<br>
> > RGB is [0..255] and I know the dimension of the image.<br>
> ><br>
> > Instead of saving it to a file I want vtk to grab the array pointer and<br>
> > display it directly. My code looks like:<br>
> ><br>
> > vtkImageImport *importer = vtkImageImport::New();<br>
> > importer->SetWholeExtent( 0, 719, 0, 479, 0, 0 );<br>
> > importer->SetDataExtentToWholeExtent();<br>
> > importer->SetDataScalarTypeToInt();<br>
> > importer->SetNumberOfScalarComponents( 3 );<br>
> > importer->SetImportVoidPointer( h.imageRGB );<br>
> ><br>
> > vtkImageFlip *flip = vtkImageFlip::New();<br>
> > flip->SetInputConnection( importer->GetOutputPort() );<br>
> > flip->SetFilteredAxis( 1 );<br>
> ><br>
> > vtkImageViewer2 *viewer = vtkImageViewer2::New();<br>
> > viewer->SetInputConnection( flip->GetOutputPort() );<br>
> > viewer->SetZSlice( 0 );<br>
> ><br>
> ><br>
> > where h.imageRGB is a pointer to integer array whose size is 720x480x3. The<br>
> > RGB are stored as [R0 G0 B0 R1 G1 B2 ... ] in h.imageRGB. The first pixel<br>
> > is on the top-left corner so I need to use vtkImageFlip to get the correct<br>
> > orientation.<br>
> ><br>
> > The resulting image displayed fine except for the colour. It looks like a<br>
> > gray-scale image where as the original US image has come coloured region.<br>
> > Can someone please shed some light into what might be wrong? Is there a<br>
> > function to get the range of pixel value (to 0 to 255)?<br>
> ><br>
> > Any help is very much appreciated,<br>
> ><br>
> > Elvis<br>
> ><br>
> > _______________________________________________<br>
> > This is the private VTK discussion list.<br>
> > Please keep messages on-topic. Check the FAQ at:<br>
> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
> ><br>
> ><br>
><br>
</div></div></blockquote></div><br>
</span></div><br>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div>