Hello everyone,<br> I met a problem about "vtkImageData". My input is a 3D point, a .BMP file and a Matrix. The matrix can transform my 3D position to 2D position. I want to find the vtkIdType of the point on the BMP file, so that I can get the color of the point. So I write some code to implement this, but it's not going well.<br>
<br> vtkBMPReader *bmp = vtkBMPReader::New();<br> bmp->SetFileName(filename);<br> bmp->Update();<br> vtkImageData *image = bmp->GetOutput();<br> <br>// x, y is the 2D position on the BMP file;<br>
vtkIdType id = image->FindPoint(x, y, 0);<br> std::cout<<"Find ID:"<<id<<std::endl;<br> vtkUnsignedCharArray *color = (vtkUnsignedCharArray *)image->GetPointData()->GetScalars();<br>
double rgb[3] = {0};<br> color->GetTupleValue(id, rgb);<br><br> The output of my code is: "Find ID: -1". So I can not get the right color. Is there anyone can help me? You assistance will be great appreciate.<br>
<br><br> Sorry for my bad English.<br><br>