[Insight-users] how to get voxel value of vtkimagedata
yas ---
yas2349 at gmail.com
Mon Feb 18 08:19:22 EST 2013
I write follow code and there is an error(error :gridVoxel[volCompIndex] =
inVolPtr[volCompIndex];)
Is my code is correct for access voxel value of vtkimagedata?
Thanks alot
// get increments for volume and for accumulation buffer
vtkIdType byteIncVol[3]; //x,y,z
volumedata->GetIncrements(byteIncVol[0],byteIncVol[1],byteIncVol[2]);
// this will store the position of the pixel being looked at
currently
int currentPos[3]; //x,y,z
int numVolumeComponents = volumedata->GetNumberOfScalarComponents()
- 1; // subtract 1 because of the alpha channel
volumedata->Update();
void *inVolPtr =volumedata->GetScalarPointer();
int *gridVoxel;
volumedata->GetScalarPointer();
double *outExt=volumedata->GetBounds();
for (int c = 0; c < numVolumeComponents; c++)
{
for (currentPos[2] = outExt[4]; currentPos[2] <= outExt[5];
currentPos[2]++)
{
for (currentPos[1] = outExt[2]; currentPos[1] <= outExt[3];
currentPos[1]++)
{
for (currentPos[0] = outExt[0]; currentPos[0] <=
outExt[1]; currentPos[0]++)
{
int volCompIndex =
(currentPos[0]*byteIncVol[0])+(currentPos[1]*byteIncVol[1])+(currentPos[2]*byteIncVol[2])+c;
gridVoxel[volCompIndex] =
inVolPtr[volCompIndex];
}
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130218/40482965/attachment.htm>
More information about the Insight-users
mailing list