Moisés Viñas Buceta

Start

	__kernel void sepia( __global uchar4* g_odata, __global uchar4* g_idata, int width, int height)
	{
		unsigned int x = get_global_id(0);
		unsigned int y = get_global_id(1);
		uchar4 pixel;
		float aux;

		pixel = g_idata[y*width+x];
		pixel.s0 = (aux=(pixel.s0*0.393f)+ (pixel.s1*0.769f) + (pixel.s2*0.189f)) < 255.0f ? aux : 255.0f;
		pixel.s1 = (aux=(pixel.s0*0.349f)+ (pixel.s1*0.686f) + (pixel.s2*0.168f)) < 255.0f ? aux : 255.0f; 
		pixel.s2 = (aux=(pixel.s0*0.272f)+ (pixel.s1*0.534f) + (pixel.s2*0.131f)) < 255.0f ? aux : 255.0f; 
		pixel.s0 = pixel.s0 / 1.351f;
		pixel.s1 = pixel.s1 / 1.203f;
		pixel.s2 = pixel.s2 / 2.140f;
		pixel.s3 = 0.0f;
		g_odata[y*width + x] = pixel;
	}