Copy Images to Device

Hi,

Is there a way to copy images to the device, I am interested in running some computer vision algorithms. Would cudaMemcopy work in this situation ?

Thanks in advance,

Regards,
iat

You would first have to read the image file into an array (1D or 2D) on the host. Once you have the image in an array on the host, you can treat it like any other array and copy it to the device using cudaMemcpy.

Depending on what you are doing, you may be able to take advantage of 2D Spatial locality through the use of texture references and cudaArrays. If this is the case, you should check out the programming guide and Dr. Dobbs articles

if you’re looking for an easy way to load images in your CPU-side code, I’ve used DevIL in the past with no complaints.

Thanks for the info. I have manged to normalize the RGB values in my image and store the converted pixel values in a 2D double array. I saw that there were a few functions in CUDA for copying host arrays to device, cudaMallocPitch(), cudaMemcpy2D(), cudaMemcpy2DArray(). What would be the best method to copy the 2D array to the device ?

Thanks in advance.

Regards,

iat