[vtkusers] speedy vtkImageData addition

mbcx9rb9 richard.j.brown at live.co.uk
Wed Nov 18 15:15:11 EST 2015


Hi all, 

I have a large vtkImageData (imgData) and I wish to add a smaller
vtkImageData (kernel) multiple times to it.

Is there a quicker way than adding each component separately?

At the moment I have something below, which is repeated for each kernel:


// indices to add kernel
int x = 10;
int y = 10;
int z = 10;

int *kerExt = kernel->GetExtent();

// all kernel elements
for (int i= kernel->GetExtent()[0]; i<= kernel->GetExtent()[1]; i++)
{
    for (int j= kernel->GetExtent()[2]; j<= kernel->GetExtent()[3]; j++)
    {
        for (int k= kernel->GetExtent()[4]; k<= kernel->GetExtent()[5]; k++)
        {
            
            // check that the point is inside the surface
            if (x+i >= imgData->GetExtent()[0] &&
                x+i <= imgData->GetExtent()[1] &&
                y+j >= imgData->GetExtent()[2] &&
                y+j <= imgData->GetExtent()[3] &&
                z+k >= imgData->GetExtent()[4] &&
                z+k <= imgData->GetExtent()[5]) 
            {
                
static_cast<double*>(imgData->GetScalarPointer(i+x,j+y,k+z))[0] +=
static_cast<double*>(kernel->GetScalarPointer(i,j,k))[0];
            }
        }
    }
}






--
View this message in context: http://vtk.1045678.n5.nabble.com/speedy-vtkImageData-addition-tp5735087.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list