# Image processing on CUDA GPU Need some help

**URL:** <https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478>\
**Category:** CUDA Programming and Performance\
**Created:** [May 17, 2011, 4:44pm UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478 "2011-05-17T16:44:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyuKa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RyuKa](https://forums.developer.nvidia.com/u/RyuKa)\
**Post date:** [May 17, 2011, 4:44pm UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478/1 "2011-05-17T16:44:12Z")

</div>

Hello everyone,

So i have a Quadro 4000 (64 blocks, and 1024 threads per block), and i need to process 10 000 images for the first loop, and then 100 other images for each in the second loop, and then process on zone/region of interest in each images (to do a correlation), let’s say 1000 max.

How can I efficiently cut theses nested loop to run the GPU at full potential … ?  
I was thinking to use the shared memory for 3 lines, 1 of the image of the first loop, and 2 of the second loop … this way, blocks can be the second loop (2\*64=128 \> 100) and threads the last loop of region of interest (1024 \> 1000, which is already a maximum).  
What do you think ? Is it possible ? I’m a beginner …

Thank you !

---

<div class="post-metadata">

**Author:** ![RyuKa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RyuKa](https://forums.developer.nvidia.com/u/RyuKa)\
**Post date:** [May 18, 2011, 6:46am UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478/2 "2011-05-18T06:46:02Z")

</div>

To be clearer :

for images from 1 to 10000  
for images from 1 to 100  
for regions from 1 to 1000  
do correlation  
end loop for region  
end loop for second images  
end loop for first images

How can I put that efficiently on CUDA ?

---

<div class="post-metadata">

**Author:** ![RyuKa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RyuKa](https://forums.developer.nvidia.com/u/RyuKa)\
**Post date:** [May 18, 2011, 9:21am UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478/3 "2011-05-18T09:21:43Z")

</div>

Maybe I can start by only making the GPU doing the correlation calculation … How can I implement the classical iFFT[FFT(images1)\*FFT(images2)] the easiest way possible ?

---

<div class="post-metadata">

**Author:** ![jm1](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jm1](https://forums.developer.nvidia.com/u/jm1)\
**Post date:** [May 19, 2011, 4:35pm UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478/4 "2011-05-19T16:35:52Z")

</div>

RyuKa,

- FFT use: there is an Nvidia FFT routine – download it from the Cuda page.
- how to organize your program? You need to understand better the GPU model; typically I use one thread per pixel. use your main Host program to keep track of the loops. copy all images to GPU board once.

JM

---

<div class="post-metadata">

**Author:** ![RyuKa](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RyuKa](https://forums.developer.nvidia.com/u/RyuKa)\
**Post date:** [May 19, 2011, 5:28pm UTC](https://forums.developer.nvidia.com/t/image-processing-on-cuda-gpu-need-some-help/22478/5 "2011-05-19T17:28:22Z")

</div>

So you think the best is to keep the loops and to only do the calculation by FFT with 1 thread per pixel ?  
I believed the main point to increase the performance was to use the shared memory (and for example do a time correlation line by line) ?
