Ejemplo n.º 1
0
            public void XYZ2RGB( float4[,] _XYZ, float4[,] _RGB )
            {
                int		W = _XYZ.GetLength( 0 );
                int		H = _XYZ.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	XYZ = _XYZ[X,Y];

                        // Transform into RGB
                        XYZ =  XYZ * MAT_XYZ2RGB;

                        // Gamma correct
                        _RGB[X,Y].x = XYZ.x > 0.0031308f ? 1.055f * (float) Math.Pow( XYZ.x, 1.0f / GAMMA_EXPONENT_sRGB ) - 0.055f : 12.92f * XYZ.x;
                        _RGB[X,Y].y = XYZ.y > 0.0031308f ? 1.055f * (float) Math.Pow( XYZ.y, 1.0f / GAMMA_EXPONENT_sRGB ) - 0.055f : 12.92f * XYZ.y;
                        _RGB[X,Y].z = XYZ.z > 0.0031308f ? 1.055f * (float) Math.Pow( XYZ.z, 1.0f / GAMMA_EXPONENT_sRGB ) - 0.055f : 12.92f * XYZ.z;
                        _RGB[X,Y].w = XYZ.w;
                    }
            }
Ejemplo n.º 2
0
            public void RGB2XYZ( float4[,] _RGB, float4[,] _XYZ )
            {
                int		W = _RGB.GetLength( 0 );
                int		H = _RGB.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	RGB = _RGB[X,Y];

                        // Gamma un-correct
                        RGB.x = (float) Math.Pow( RGB.x, GAMMA_EXPONENT_ADOBE );
                        RGB.y = (float) Math.Pow( RGB.y, GAMMA_EXPONENT_ADOBE );
                        RGB.z = (float) Math.Pow( RGB.z, GAMMA_EXPONENT_ADOBE );

                        // Transform into XYZ
                        _XYZ[X,Y] = RGB * MAT_RGB2XYZ;
                    }
            }
Ejemplo n.º 3
0
 public void XYZ2RGB( float4[,] _XYZ, float4[,] _RGB )
 {
     int		W = _XYZ.GetLength( 0 );
     int		H = _XYZ.GetLength( 1 );
     for ( int Y=0; Y < H; Y++ )
         for ( int X=0; X < W; X++ )
             _RGB[X,Y] = _XYZ[X,Y] * MAT_XYZ2RGB;
 }
Ejemplo n.º 4
0
            public void RGB2XYZ( float4[,] _RGB, float4[,] _XYZ )
            {
                int		W = _RGB.GetLength( 0 );
                int		H = _RGB.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	RGB = _RGB[X,Y];

                        // Gamma un-correct
                        RGB.x = RGB.x < 0.04045f ? RGB.x / 12.92f : (float) Math.Pow( (RGB.x + 0.055f) / 1.055f, GAMMA_EXPONENT_sRGB );
                        RGB.y = RGB.y < 0.04045f ? RGB.y / 12.92f : (float) Math.Pow( (RGB.y + 0.055f) / 1.055f, GAMMA_EXPONENT_sRGB );
                        RGB.z = RGB.z < 0.04045f ? RGB.z / 12.92f : (float) Math.Pow( (RGB.z + 0.055f) / 1.055f, GAMMA_EXPONENT_sRGB );

                        // Transform into XYZ
                        _XYZ[X,Y] =  RGB *  MAT_RGB2XYZ;
                    }
            }
Ejemplo n.º 5
0
 public void RGB2XYZ( float4[,] _RGB, float4[,] _XYZ )
 {
     int		W = _RGB.GetLength( 0 );
     int		H = _RGB.GetLength( 1 );
     for ( int Y=0; Y < H; Y++ )
         for ( int X=0; X < W; X++ )
             _XYZ[X,Y] = _RGB[X,Y] * MAT_RGB2XYZ;
 }
Ejemplo n.º 6
0
            public void RGB2XYZ( float4[,] _RGB, float4[,] _XYZ )
            {
                int		W = _RGB.GetLength( 0 );
                int		H = _RGB.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	RGB = _RGB[X,Y];

                        // Gamma un-correct
                        RGB.x = RGB.x > 0.031248f ? (float) Math.Pow( RGB.x, GAMMA_EXPONENT_PRO_PHOTO ) : RGB.x / 16.0f;
                        RGB.y = RGB.y > 0.031248f ? (float) Math.Pow( RGB.y, GAMMA_EXPONENT_PRO_PHOTO ) : RGB.y / 16.0f;
                        RGB.z = RGB.z > 0.031248f ? (float) Math.Pow( RGB.z, GAMMA_EXPONENT_PRO_PHOTO ) : RGB.z / 16.0f;

                        // Transform into XYZ
                        _XYZ[X,Y] = RGB * MAT_RGB2XYZ;
                    }
            }
Ejemplo n.º 7
0
            public void XYZ2RGB( float4[,] _XYZ, float4[,] _RGB )
            {
                int		W = _XYZ.GetLength( 0 );
                int		H = _XYZ.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	XYZ = _XYZ[X,Y];

                        // Transform into RGB
                        XYZ = XYZ * m_XYZ2RGB;

                        // Gamma correct
                        _RGB[X,Y].x = (float) Math.Pow( XYZ.x, m_InvGamma );
                        _RGB[X,Y].y = (float) Math.Pow( XYZ.y, m_InvGamma );
                        _RGB[X,Y].z = (float) Math.Pow( XYZ.z, m_InvGamma );
                        _RGB[X,Y].w = XYZ.w;
                    }
            }
Ejemplo n.º 8
0
            public void XYZ2RGB( float4[,] _XYZ, float4[,] _RGB )
            {
                int		W = _XYZ.GetLength( 0 );
                int		H = _XYZ.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	XYZ = _XYZ[X,Y];

                        // Transform into RGB
                        XYZ = XYZ * m_XYZ2RGB;

                        // Gamma correct
                        _RGB[X,Y].x = XYZ.x > 0.001953f ? (float) Math.Pow( XYZ.x, 1.0f / GAMMA_EXPONENT_PRO_PHOTO ) : 16.0f * XYZ.x;
                        _RGB[X,Y].y = XYZ.y > 0.001953f ? (float) Math.Pow( XYZ.y, 1.0f / GAMMA_EXPONENT_PRO_PHOTO ) : 16.0f * XYZ.y;
                        _RGB[X,Y].z = XYZ.z > 0.001953f ? (float) Math.Pow( XYZ.z, 1.0f / GAMMA_EXPONENT_PRO_PHOTO ) : 16.0f * XYZ.z;
                        _RGB[X,Y].w = XYZ.w;
                    }
            }
Ejemplo n.º 9
0
            public void XYZ2RGB( float4[,] _XYZ, float4[,] _RGB )
            {
                int		W = _XYZ.GetLength( 0 );
                int		H = _XYZ.GetLength( 1 );
                for ( int Y=0; Y < H; Y++ )
                    for ( int X=0; X < W; X++ )
                    {
                        float4	XYZ = _XYZ[X,Y];

                        // Transform into RGB
                        XYZ = XYZ * MAT_XYZ2RGB;

                        // Gamma correct
                        _RGB[X,Y].x = (float) Math.Pow( XYZ.x, 1.0f / GAMMA_EXPONENT_ADOBE );
                        _RGB[X,Y].y = (float) Math.Pow( XYZ.y, 1.0f / GAMMA_EXPONENT_ADOBE );
                        _RGB[X,Y].z = (float) Math.Pow( XYZ.z, 1.0f / GAMMA_EXPONENT_ADOBE );
                        _RGB[X,Y].w = XYZ.w;
                    }
            }