[vtkusers] fill vtkImageData in 3D

David Doria daviddoria at gmail.com
Fri Jan 7 14:49:40 EST 2011


On Fri, Jan 7, 2011 at 2:45 PM, Rachel <aracha2010 at gmail.com> wrote:

>
> Hi Kwayeke,
>
> this is color image. To change the color R, G ,B try with this inside the
> loop
>
> Image->SetScalarComponentFromDouble(x,y,z,0, R);
> Image->SetScalarComponentFromDouble(x,y,z,1, G);
> Image->SetScalarComponentFromDouble(x,y,z,2, B);
>

Or do this:
double* pixel = static_cast<double*>(ImageData->GetScalarPointer(k,j,i));
pixel[0] = r;
pixel[1] = g;
pixel[2] = b;

This way if it is not double the only thing that changes is the 'pixel'
pointer and the cast - you don't have to think about
what SetScalarComponentFromDouble is doing.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110107/cc11b3de/attachment.htm>


More information about the vtkusers mailing list