RGB2HSV color conversion Kernel

I am looking for information on doing this color conversion. I did find this kernel online which looks pretty straight forward.


The signature function is

extern “C” void convert_to_hsv_wrapper(uchar4 *rgb, float4 *hsv, int width, int height)

When I load an RGB image in to a vx_image I use vxImagePatch to get a pointer to the base data and cast this to a uchar4 * and pass it to the kernel but the thing just blows up. Any ideas?

Blows up how? Are you passing host pointers to the kernel, by any chance?

Is the data saved as a uchar4 ? That is be 32-bits or four bytes for each pixel. Usually the image data is not saved like that. There are many ways possible so you have to make sure the data is actually stored with four bytes per pixel - that’s what the uchar4 means.

As njuffa wrote, you also have to make sure you are passing a pointer to data in device-accessible memory or your program will detonate.

I think my mistake was assuming that the vx_image was on the GPU, it seems it is not. Once I do a cudaMalloc and and a cudaMemcpy of the data from the vx_image to memory and then call the kernel function it seems to work. Does this sound about right?

Yes, it does. Good luck.