[vtkusers] speedy vtkImageData addition
Dženan Zukić
dzenanz at gmail.com
Thu Nov 19 17:03:10 EST 2015
There is a convolution class, I don't know whether you can make it work for
your case:
http://www.vtk.org/doc/nightly/html/classvtkImageConvolve.html
HTH
On Wed, Nov 18, 2015 at 3:15 PM, mbcx9rb9 <richard.j.brown at live.co.uk>
wrote:
> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151119/1cd2da76/attachment.html>
More information about the vtkusers
mailing list