[vtkusers] vtkImageData::GetScalarPointer is slow inside the loop?
Mengda Wu
wumengda at gmail.com
Tue Nov 19 23:30:02 EST 2013
Hi all,
I am trying to use vtkImageData::GetScalarPointer inside the loop
through all the voxels in a huge 3D image (512x512x300). But it seems this
function is pretty slow. A code sample is like this:
int* dims = aImage->GetDimensions();
int dim[3];
for(dim[2] = 0; dim[2] < dims[2]; dim[2]++)
{
for(dim[1] = 0; dim[1] < dims[1]; dim[1]++)
{
for(dim[0] = 0; dim[0] < dims[0]; dim[0]++)
{
double* curr =
static_cast<double*>(aImage->GetScalarPointer(dim));
*currhist = 1.0;
}
}
}
}
I mean should I just get the pointer of the first vosel and compute the
poitner addresses for the rest of voxels myself? Should it be faster? Does
vtkImageData store all voxels continuously? What about if I have multiple
components per voxel?
Thanks,
Mengda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131119/fe4f9db5/attachment.htm>
More information about the vtkusers
mailing list