[vtkusers] A problem about vtkImageData and Project
周敏明
zmmbreeze0825 at gmail.com
Wed Apr 1 13:44:43 EDT 2009
Hello everyone,
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.
vtkBMPReader *bmp = vtkBMPReader::New();
bmp->SetFileName(filename);
bmp->Update();
vtkImageData *image = bmp->GetOutput();
// x, y is the 2D position on the BMP file;
vtkIdType id = image->FindPoint(x, y, 0);
std::cout<<"Find ID:"<<id<<std::endl;
vtkUnsignedCharArray *color = (vtkUnsignedCharArray
*)image->GetPointData()->GetScalars();
double rgb[3] = {0};
color->GetTupleValue(id, rgb);
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.
Sorry for my bad English.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090402/8e40d569/attachment.htm>
More information about the vtkusers
mailing list