Hi,<br>I have developed a program to display 3D ultrasound raw data, and everything goes well. Now I want to extend my work by displaying some 3D RGB raw data, but I failed. <br><br>I have found somebody's suggestion on the mailing list, the suggestion is that, first quantizing the color to a small set of colors ,and then build a lookup table for it. I have tried this, but it does not work. Maybe I did it in a wrong way.<br>
<br>now I have a 3D RGB raw data, and there are 3 components( the r,g,b value; 8 bit ) in each scalar, and I have successfully created a vtkImageData, and I want to display a single slice of this image data. I choose to use vtkReslice to display the sagittal, coronal and axial slices; and I choose to use vtkImagePlaneWidget to display these slices together. They all work perfectly with grey scale raw data. <br>
<br>So how to build up a lookup table for rgb data? or how to quantizing my data to a small set of colors?<br>Besides, can we display the data directly without building a lookup table, since the value itself is RGB value already?<br>
<br>Thank you very much for your help.<br><br>Saifeng,<br><br>How I create the vtkImageData, and read in some binary data.<br>//***********************************<br>vtkImageData* id = vtkImageData::New();<br> id->SetDimensions(256,256,256);<br>
id->SetSpacing(1,1,1);<br> id->SetScalarTypeToUnsignedChar();<br> id->SetNumberOfScalarComponents(3);// the r,g,b value.<br> id->SetOrigin(0.0,0.0,0.0);<br> id->AllocateScalars();<br clear="all"><br>//Then I fill in the image data with my raw data.<br>
ifstream infile("/home/Rawdata/rgbcube.raw",ios::in|ios::binary);<br>int size=256*256*256*3;<br>unsigned char *buf=new unsigned char [size];<br>infile.read((char *)buf,size);<br>infile.close();<br><br>//fill in imagedata;<br>
unsigned char *ptr = (unsigned char *) id->GetScalarPointer();<br>int i;<br>for(i=0;i<size;i++)<br>{<br> *ptr=buf[i];<br> ptr++;<br>}<br>cout<<"imagedata filled"<<endl; <br>//then set up a vtkreslice<br>
-- <br>Saifeng Liu<br>Department of Biomedical Engineering<br>Huazhong University of Science and Technology,<br>Wuhan, China<br>Tel:86-15827367525(mobile), 86-27-87442691<br>