<div dir="ltr">Hi Richard,<div><br></div><div>SetInformationInput(), not SetInformation(). The former (the one you need to use) requires a vtkImageData as input. It provides the reference image that defines the geometry for the reslicing.</div><div><br></div><div> - David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 20, 2016 at 7:55 AM, Richard Brown <span dir="ltr"><<a href="mailto:richard.j.brown@live.co.uk" target="_blank">richard.j.brown@live.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi David, <div><br></div><div>I’ve been working through your advice and I get an error:</div><div><span style="white-space:pre-wrap"> </span><span style="font-family:Menlo;font-size:14px">Attempt to get an input array for an index that has not been specified</span></div><div><span style="font-family:Menlo;font-size:14px"><br></span></div><div>My code looks like yours:</div><div><span style="white-space:pre-wrap"> </span> <span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageReslice</span>><span style="color:rgb(192,192,192)"> </span>imageReslice<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageReslice</span>>::New();</div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>imageReslice->SetInputData(kernelImageData);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>imageReslice-><span style="font-style:italic">SetInformation</span>(doseGrid-><span style="font-style:italic">GetInformation</span>());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>imageReslice->SetInterpolationModeToLinear();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>imageReslice-><span style="font-style:italic">SetResliceTransform</span>(transform);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>imageReslice-><span style="font-style:italic">Update</span>();</pre><div><br></div><div>It seems like the error is coming from doseGrid (when I comment it out, the error goes away). The dose grid was initialised like this:</div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800080"> vtkSmartPointer</span><<span style="color:#800080">vtkImageData</span>><span style="color:#c0c0c0"> </span>doseGrid<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkSmartPointer</span><<span style="color:#800080">vtkImageData</span>>::New();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>doseGrid-><span style="font-style:italic">SetOrigin</span>(<span style="color:#000080">0.</span>,<span style="color:#000080">0.</span>,<span style="color:#000080">0.</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>doseGrid-><span style="font-style:italic">SetDimensions</span>(<span style="color:#000080">500</span>,<span style="color:#000080">500</span>,<span style="color:#000080">500</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>doseGrid-><span style="font-style:italic">SetSpacing</span>(<span style="color:#000080">0.5</span>,<span style="color:#000080">0.5</span>,<span style="color:#000080">0.5</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>doseGrid-><span style="font-style:italic">AllocateScalars</span>(<span style="color:#000080">VTK_DOUBLE</span>,<span style="color:#000080">1</span>);</pre><div><br></div></div><div>Any idea what I’ve done wrong?</div><div><br></div><div>Regards,</div><div>Richard</div><div><div class="h5"><div><br><div><blockquote type="cite"><div>On 08 Jul 2016, at 17:42, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Hi Richard,<div><br></div><div>Yes, you can use vtkImageReslice for this. It would work like this:</div><div><br></div><div>Let's define T as the transform that gives the position and orientation of the kernel within the larger image. To resample the kernel, you would give vtkImageReslice the inverse of T as the ResliceTransform, and you would supply the larger image as a reference image, e.g. the code would look like this (using Python):</div><div><br></div><div>reslice = vtkImageReslice()</div><div>reslice.SetInputData(kernel_image)</div><div>reslice.SetInformationInput(big_image)</div><div>reslice.SetResliceTransform(inverse_transform)</div><div>reslice.SetInterpolationModeToLinear()</div><div>reslice.Update()</div><div><br></div><div>This will produce something like the bottom image from your original email. In order for the kernel resampling to work properly, your kernel image must have a border which is all zeros. If this must be done over and over again (i.e. if you need to superimpose the kernel hundreds of times at various locations within the larger image) then the above procedure won't be fast enough. Another possibility is to use the vtkImageInterpolator class and some of your own ingenuity to create a fast method for resampling and superposing the kernel.</div><div><br></div><div>During my PhD, I wrote a custom VTK class that superposed kernels into a volume in order to do 3D ultrasound reconstruction, but I never generalized it:</div><div><a href="https://github.com/dgobbi/AIGS/blob/master/Ultrasound/vtkFreehandUltrasound.h" target="_blank">https://github.com/dgobbi/AIGS/blob/master/Ultrasound/vtkFreehandUltrasound.h</a></div><div><br></div><div>Some further development of this code was done for the PLUS toolkit:</div><div><a href="https://app.assembla.com/spaces/plus/subversion/source/HEAD/trunk/PlusLib/src/PlusVolumeReconstruction" target="_blank">https://app.assembla.com/spaces/plus/subversion/source/HEAD/trunk/PlusLib/src/PlusVolumeReconstruction</a></div><div><br></div><div>However, as far as I know, VTK doesn't provide an efficient general-purpose way of superposing kernels at different positions and orientations into a 3D volume.</div><div><br></div><div> - David</div><div><br></div><div><br></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 8, 2016 at 7:07 AM, Richard Brown <span dir="ltr"><<a href="mailto:richard.j.brown@live.co.uk" target="_blank">richard.j.brown@live.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br>
Hi all,<div><br></div><div>I have a fairly simple problem, and one that I’m sure has previously been solved here, but I’m struggling to find the right keywords to find a useful thread.</div><div><br></div><div>I would like to superpose a kernel vtkImageData (kernel.png) onto a grid vtkImageData (grid.png). The kernel will be rotated (superpose.png), however, so the kernel will requiring resampling before superposition is possible (superposition_and_resample.png).</div><div><br></div><div>What is the best way to do this? I feel like I can simply use vtkImageReslice, but I’m not 100%. </div><div><br></div><div>Thanks in advance for any pointers.</div><div><br></div><div>Regards,</div><div>Richard</div></div></blockquote></div><br></div></div></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>