Cuda handle only with PGM or PPM format image ?

new to cuda :)

It seems that man can only load pgm or ppm format images into memories by using the functions below ???
CUT_SAFE_CALL(cutSavePGMf(name1, img1.h_data, dataW1, dataH1));
CUT_SAFE_CALL(cutLoadPGMf(name1, &indata, &dataW1, &dataH1));

other format (jpg,png) can’t be loaded??? only pgm or ppm ??? why ?


I use opencv, loads many different formats.

yes, I use openCV, too.

the problem is how to transfer the imagedata from openCV to cuda?

that is: transfer the data format char (0 to 255 ) to the float format (0.0f to 1.0f) ???

By using openCV all the loaded imagedata (by using the function cvLoadImage) are saved in IplImage->imageData , which is char*. So how can I used these imagedata in Cuda ? because Cuda handle only float formats, which means the imageData are from 0.0f to 1.0f but in OpenCV the imageData are saved

by char from 0 to 255.

who has also this problem ?

pls help me .


CUDA handles more than float formats IIRC. You could probably do char calculations, though I haven’t tried.

I’m doing some basic image processing, and I convert to float, so I don’t have experience with integer data formats.

To convert, you can do something like this:

float charToFloatMult = 1.0f / CHAR_MAX;

for (int i = 0; i < charArraySize; i++)


  floatArray = charArray[i] * charToFloatMult;



Edit: that was supposed to be the maximum for unsigned chars of course, changed 127 to 255 to avoid misunderstandings.

If you’re using textures, just set them up to return normalized floats. Otherwise do the conversion manually, as suggested by a previous post.


Simply do a memcpy form the IplImage -> imageData to the GPU and
then you can handle the data as an array of unsigned char values or as a normalized float texture as paulius already suggested.