[vtkusers] Get pixel intensity

Cory Quammen cquammen at cs.unc.edu
Sat Jul 22 12:54:41 EDT 2006


Here's a simpler way to grab values from a vtkImageData object:

vtkImageData *foo = ...;
double scalar = foo->GetScalarComponentAsDouble(x, y, z, component);

where component = 0 if you have just one scalar component in your image.

It may be slow if you are looping through your entire image, though, so you
may want to use the method described by Chase and Torsten. But if you want
just one value or several values, the above works pretty well.

Cory

Hi Andres,
>
> Here is one way to do it:
>
> vtkImageData *foo;
> int *dimensions = foo->GetDimensions();
> pixelValue =
> foo->GetPointData()->GetScalar
> s()->GetTuple1(x+y*dimensions[0]+z*dimensions[0]*dimensions[1]);
>
> Anyone have a better way?
>
> Chase Yarbrough
>
> Andres Munarriz wrote:
> > Hi everyone,
> >
> > I'm pretty sure someone has already posted a similar question if not
> > the same (for this I apologize), but I haven't been able to find such
> > post.  Is there a way to retrieve the pixel intensity at a particular
> > index from a vtkImageData object?  Under ITK one can " make" the index
> > then get the pixelData from it.
> >
> >
> > Thanks in advance,
> >
> > Andres E. Munarriz Soto
>


-- 
Cory Quammen
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060722/bea7de58/attachment.htm>


More information about the vtkusers mailing list