Moisés Viñas Buceta

Start

void sepia( Array< uchar4, 1 > g_odata, Array< uchar4, 1 >  g_idata, Int width, Int height)
{
        Uchar4 pixel;
        Float aux;

        pixel = g_idata[idy*width+idx];
        pixel[0] = where((aux=((pixel[0]*0.393f)+ (pixel[1]*0.769f) + (pixel[2]*0.189f)))<255.0f, aux, 255.0f);
        pixel[1] = where((aux=((pixel[0]*0.349f)+ (pixel[1]*0.686f) + (pixel[2]*0.168f)))<255.0f, aux, 255.0f);
        pixel[2] = where((aux=((pixel[0]*0.272f)+ (pixel[1]*0.534f) + (pixel[2]*0.131f)))<255.0f, aux, 255.0f);
        pixel[0] = pixel[0] / 1.351f;
        pixel[1] = pixel[1] / 1.203f;
        pixel[2] = pixel[2] / 2.140f;
        pixel[3] = 0.0f;
        g_odata[idy*width + idx] = pixel;
}