<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dzenan,<div class=""><br class=""></div><div class="">Thanks for the reply but I think this was what I was looking for:</div><div class=""><a href="http://vtk.1045678.n5.nabble.com/vtkImageData-GetScalarPointer-is-slow-inside-the-loop-td5724517.html" class="">http://vtk.1045678.n5.nabble.com/vtkImageData-GetScalarPointer-is-slow-inside-the-loop-td5724517.html</a></div><div class=""><br class=""></div><div class="">The static cast each time was really slowing the process down.</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Rich</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 19 Nov 2015, at 23:03, Dženan Zukić <<a href="mailto:dzenanz@gmail.com" class="">dzenanz@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">There is a convolution class, I don't know whether you can make it work for your case:</div><div class="gmail_default" style=""><font face="verdana, sans-serif" class=""><a href="http://www.vtk.org/doc/nightly/html/classvtkImageConvolve.html" class="">http://www.vtk.org/doc/nightly/html/classvtkImageConvolve.html</a></font><br class=""></div><div class="gmail_default" style=""><font face="verdana, sans-serif" class=""><br class=""></font></div><div class="gmail_default" style=""><font face="verdana, sans-serif" class="">HTH</font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 18, 2015 at 3:15 PM, mbcx9rb9 <span dir="ltr" class=""><<a href="mailto:richard.j.brown@live.co.uk" target="_blank" class="">richard.j.brown@live.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br class="">
<br class="">
I have a large vtkImageData (imgData) and I wish to add a smaller<br class="">
vtkImageData (kernel) multiple times to it.<br class="">
<br class="">
Is there a quicker way than adding each component separately?<br class="">
<br class="">
At the moment I have something below, which is repeated for each kernel:<br class="">
<br class="">
<br class="">
// indices to add kernel<br class="">
int x = 10;<br class="">
int y = 10;<br class="">
int z = 10;<br class="">
<br class="">
int *kerExt = kernel->GetExtent();<br class="">
<br class="">
// all kernel elements<br class="">
for (int i= kernel->GetExtent()[0]; i<= kernel->GetExtent()[1]; i++)<br class="">
{<br class="">
for (int j= kernel->GetExtent()[2]; j<= kernel->GetExtent()[3]; j++)<br class="">
{<br class="">
for (int k= kernel->GetExtent()[4]; k<= kernel->GetExtent()[5]; k++)<br class="">
{<br class="">
<br class="">
// check that the point is inside the surface<br class="">
if (x+i >= imgData->GetExtent()[0] &&<br class="">
x+i <= imgData->GetExtent()[1] &&<br class="">
y+j >= imgData->GetExtent()[2] &&<br class="">
y+j <= imgData->GetExtent()[3] &&<br class="">
z+k >= imgData->GetExtent()[4] &&<br class="">
z+k <= imgData->GetExtent()[5])<br class="">
{<br class="">
<br class="">
static_cast<double*>(imgData->GetScalarPointer(i+x,j+y,k+z))[0] +=<br class="">
static_cast<double*>(kernel->GetScalarPointer(i,j,k))[0];<br class="">
}<br class="">
}<br class="">
}<br class="">
}<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
--<br class="">
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/speedy-vtkImageData-addition-tp5735087.html" rel="noreferrer" target="_blank" class="">http://vtk.1045678.n5.nabble.com/speedy-vtkImageData-addition-tp5735087.html</a><br class="">
Sent from the VTK - Users mailing list archive at <a href="http://Nabble.com" class="">Nabble.com</a>.<br class="">
_______________________________________________<br class="">
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" class="">http://www.kitware.com/opensource/opensource.html</a><br class="">
<br class="">
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank" class="">http://www.vtk.org/Wiki/VTK_FAQ</a><br class="">
<br class="">
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank" class="">http://markmail.org/search/?q=vtkusers</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank" class="">http://public.kitware.com/mailman/listinfo/vtkusers</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>