Res: [vtkusers] gray value of image

Wagner Sales wsalles2003 at yahoo.com.br
Thu Apr 26 18:39:32 EDT 2007


Sergi,

I'll assume some points before put these solution:
1 - You have the coordinates;
2 - You was rescaled/shifted the image to view ( I think the solution can works if not shifted/rescaled too );
3 - You are using C++.

This piece of code will do it for you, and are based on another piece of code of vtkImagePlaneWidget class:


double YourClass::computeScalarValue( double *coords)
{
  if(!ImageData || !coords ) return 0.0;


  double tol2;
  vtkCell *cell;
  vtkPointData *pd;
  int subId;
  double pcoords[3], weights[8];


  pd = ImageData->GetPointData();

  vtkPointData* outPD = vtkPointData::New();
  outPD->InterpolateAllocate(pd, 1, 1);

  tol2 = ImageData->GetLength();
  tol2 = tol2 ? tol2*tol2 / 1000.0 : 0.001;

  cell = ImageData->FindAndGetCell(coords,NULL,-1,tol2,subId,pcoords,weights);
  if (cell)
    {
        outPD->InterpolatePoint(pd,0,cell->PointIds,weights);
        return outPD->GetScalars()->GetTuple1(0);
    } else {
        return -1;
        }

  outPD->Delete();
}

----- Mensagem original ----
De: Sergi Dote <sergidt at gmail.com>
Para: vtkusers at vtk.org
Enviadas: Quinta-feira, 26 de Abril de 2007 9:08:02
Assunto: [vtkusers] gray value of image

Hello vtkUsers, I need your knowledge:

I work with a volume (gray CT) and  I want to get the gray value of a point of this volume specified by world coordinates; this is, for example I ask what is gray value of a point Xmin=
33.2 Xmax =123.2 Ymin=14.1 Ymax=15.6 Zmin=11 Zmax=11 and I need to have this value.

Somebody knows how can I do this?

thank you very much!!

-- 
.: Sergi Dote Teixidor :.
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers






__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070426/e027a131/attachment.htm>


More information about the vtkusers mailing list