<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Gordian,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">this approach looks like it should work. What is wrong with it?</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default"><font face="verdana, sans-serif">Dženan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)</font></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 28, 2017 at 9:51 AM, Kabelitz, Gordian <span dir="ltr"><<a href="mailto:Gordian.Kabelitz@medma.uni-heidelberg.de" target="_blank">Gordian.Kabelitz@medma.uni-heidelberg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
i computed a gradient with my own function and as a result a pointer to an image buffer is provided. I know the size, origin and spacing of the gradient component image.<br>
I want to copy the gradient image into an itk::VectorImage with the components for the x,y,z gradients.<br>
<br>
The way I copied the image to the GPU is that I retrieved the buffer pointer from my input image and use the pointer to copy the image data to the GPU.<br>
I used the way proposed in [1]. The computeGradientImage method is listed at the end of this mail.<br>
<br>
[...]<br>
// get float pointer to image data<br>
ImageType::Pointer image = reader->GetOutput();<br>
Image->Update();<br>
<br>
float* data = image.GetBufferPointer();<br>
// copy image data to GPU texture memory (this works)<br>
gpu_dev->setVoxels(dimension, voxelSize, data);<br>
[...]<br>
computeGradientImage<<<n,m>>> (dev_gradientImage, dimension);<br>
<br>
// copy resulting gradientImage to host variable<br>
float4* host_gradientImage;<br>
cudaMemcpy(host_gradient, dev_gradientImage, numberOfVoxels*sizeof(float4))<wbr>;<br>
<br>
--> Pseudo Code <--<br>
// Now I want to reverse the copy process. I have a float4 image and want to copy this into a itk::VectorImage with VariableVectorLength of 3 (skipping the magnitude value).<br>
[...] -> size, spacing, origin, region definition<br>
Itk::VectorImageType vecImage = VectorImageType::New();<br>
vecImage->setRegion(region);<br>
vecImage ->SetVectorLength(3);<br>
vecImage->Allocate();<br>
<br>
// copy image buffer to vecImage, component by component<br>
auto vecBuffer = vecImage->getBufferPointer();<br>
auto j = 0;<br>
for (i=0; i<totalVoxel; ++i)<br>
{<br>
        vecbuffer[j] = host_gradient[i].x; j++;<br>
        vecbuffer[j] = host_gradient[i].y; j++;<br>
        vecbuffer[j] = host_gradient[i].z; j++;<br>
}<br>
<br>
// save vecImage as nrrd image<br>
[...]<br>
<br>
I haven't found a way to achieve my idea.<br>
Are there any suggestions or examples?<br>
As far I can see I cannot use the itk::ImportImageFilter.<br>
<br>
Thank you for any suggestions.<br>
With kind regards,<br>
Gordian<br>
<br>
[1]: <a href="https://itk.org/CourseWare/Training/GettingStarted-V.pdf" rel="noreferrer" target="_blank">https://itk.org/CourseWare/<wbr>Training/GettingStarted-V.pdf</a><br>
<br>
void computeGradientImage(float4* gradientImage, int* dimension)<br>
{<br>
        // every thread computes the float4 voxel with theta,phi,magnitude from gradient image<br>
        int idx = blockIdx.x * blockDim.x + threadIdx.x;<br>
        int idy = blockIdx.y * blockDim.y + threadIdx.y;<br>
        int idz = blockIdx.z * blockDim.z + threadIdx.z;<br>
<br>
        if (idx < dimension[0] && idy < dimension[1] && idz < dimension[2])<br>
        {<br>
                // define sobel filter for each direction<br>
                [...]<br>
<br>
                // run sobel on image in texture memory for each direction and put result into a float4 image<br>
                gradientImage[idx + dimension[0] * (idy + idz * dimension[1])] = make_float4(sobelX, sobelY, sobelZ, magn);<br>
        }<br>
}<br>
<br>
<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>