[vtkusers] speedy vtkImageData addition

Richard Brown richard.j.brown at live.co.uk
Fri Nov 20 09:43:42 EST 2015


Dzenan,

Thanks for the reply but I think this was what I was looking for:
http://vtk.1045678.n5.nabble.com/vtkImageData-GetScalarPointer-is-slow-inside-the-loop-td5724517.html <http://vtk.1045678.n5.nabble.com/vtkImageData-GetScalarPointer-is-slow-inside-the-loop-td5724517.html>

The static cast each time was really slowing the process down.

Regards,
Rich

> On 19 Nov 2015, at 23:03, Dženan Zukić <dzenanz at gmail.com> wrote:
> 
> 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 <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 <mailto: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 <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 <http://www.kitware.com/>
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html <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 <http://www.vtk.org/Wiki/VTK_FAQ>
> 
> Search the list archives at: http://markmail.org/search/?q=vtkusers <http://markmail.org/search/?q=vtkusers>
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers <http://public.kitware.com/mailman/listinfo/vtkusers>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151120/f2e79319/attachment.html>


More information about the vtkusers mailing list