Using float2, float3 How to access the data


I am new to CUDA and I have what is certain to be a very simple question:

Should I use float2 and float3 for arrays? Lets say I have an image that is 512x512 and I want to know the pixel value at i=12 and j=156, how would I do that using float2? Is float2 even appropriate in this context.

I can’t seem to find examples where a simple subscript like Image[12,156]=value is used. I am very confused.


Images are usualy stored as unsigned chars (from 0 to 255) so if anything i would use an int3 for 3 channels pixels (red green blue).
So you would need either a 2d array of int3’s or a “flattened” 1d array.

Youre thinking a float2 is for storing 2 dimensions, but it is not.

float2 is a struct containing two floats, float2.x and float2.y.

Unless i misunderstood your question and without the intent of sounding condescending, I can only suggest digging more into traditionnal programming since this is more a “image processing programming” than a “cuda image processing programming” question.

Thanks for the help.

Reading my own post post… i dont know what i was thinking…
I meant uchar3 not int3… an int3 would be overkill and a waste of space.