Hello guys, I have a kernel to manipulate a image, I’m using image2D to do it and I need to get the neighborhood pixels of the actual pixel, the way i figured out to do it was this way:
float4 b1, b2, b3, b4, b5, b6, b7, b8, b9;
b1 = read_imagef(buffer, sampler, (x - 1, y - 1));
b2 = read_imagef(buffer, sampler, (x, y - 1));
b3 = read_imagef(buffer, sampler, (x + 1, y - 1));
b4 = read_imagef(buffer, sampler, (x - 1, y));
b5 = read_imagef(buffer, sampler, (x, y));
b6 = read_imagef(buffer, sampler, (x + 1, y));
b7 = read_imagef(buffer, sampler, (x - 1, y + 1));
b8 = read_imagef(buffer, sampler, (x, y + 1));
b9 = read_imagef(buffer, sampler, (x + 1, y + 1));
this way i have 9 float4 variables making an kernel 3x3, but I wonder if there is a more efficient way to do it, I’m open to ideas.
ps: for border I’m using CLK_ADDRESS_CLAMP_TO_EDGE
Thanks!