__kernel void imgrotate(__global unsigned char *in, __global unsigned char *out, int width, int height, int rx, int ry, float radians){ const int i = get_global_id(0); float new_x = i % width; float new_y = i / width; float r = sqrt(pow((new_x - rx), 2.0f) + pow((new_y - ry), 2.0f)); float ot = atan2( new_y - ry, new_x - rx ); float t = radians + ot; float original_x = r * cos(t) + rx; float original_y = r * sin(t) + ry; int np = (int)round(round(new_y) * width + new_x); if(r < 50){ out[0 + 3*np] = 0; out[1 + 3*np] = 255; out[2 + 3*np] = 128; return; } if(original_y < 0 || original_y > height || original_x < 0 || original_x > width){ out[0 + 3*np] = 0; out[1 + 3*np] = 0; out[2 + 3*np] = 0; return; } int op = (int)round(round(original_y) * width + original_x); out[3 * np] = in[3 * op]; out[1 + 3 * np] = in[1 + 3 * op]; out[2 + 3 * np] = in[2 + 3 * op]; } __kernel void imgcompare(__global unsigned char *a, __global unsigned char *b, __global unsigned int *res, int width){ const int i = get_global_id(0); int offset = i * width; res[i] = 0; for(int j = 0; j < width*3; j++){ res[i] += abs(a[offset + j] - b[offset + j]); } }