hello,<br><br>I'm trying to import video/still-images from an ultra-sound machine and display it using vtk. I can grab an image from the frame-grabber and save the image as PPM (basically RGB values with some headers). The range of the 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 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 RGB are stored as [R0 G0 B0 R1 G1 B2 ... ] in h.imageRGB. The first pixel is on the top-left corner so I need to use vtkImageFlip to get the correct orientation.<br>
<br>The resulting image displayed fine except for the colour. It looks like a gray-scale image where as the original US image has come coloured region. Can someone please shed some light into what might be wrong? Is there a function to get the range of pixel value (to 0 to 255)?<br>
<br>Any help is very much appreciated,<br><br>Elvis<br>