public static XMVector YuvToRgbHD(XMVector yuv) { XMVector scale1 = XMVector.FromFloat(0.0f, -0.2153f, 2.1324f, 0.0f); XMVector scale2 = XMVector.FromFloat(1.2803f, -0.3806f, 0.0f, 0.0f); XMMatrix m = new XMMatrix(XMGlobalConstants.One, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(yuv, m); return(XMVector.Select(yuv, clr, XMGlobalConstants.Select1110)); }
public static XMVector YuvToRgb(XMVector yuv) { XMVector scale1 = XMVector.FromFloat(0.0f, -0.395f, 2.032f, 0.0f); XMVector scale2 = XMVector.FromFloat(1.140f, -0.581f, 0.0f, 0.0f); XMMatrix m = new XMMatrix(XMGlobalConstants.One, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(yuv, m); return(XMVector.Select(yuv, clr, XMGlobalConstants.Select1110)); }
public static XMVector RgbToYuvHD(XMVector rgb) { XMVector scale0 = XMVector.FromFloat(0.2126f, -0.0997f, 0.6150f, 0.0f); XMVector scale1 = XMVector.FromFloat(0.7152f, -0.3354f, -0.5586f, 0.0f); XMVector scale2 = XMVector.FromFloat(0.0722f, 0.4351f, -0.0564f, 0.0f); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(rgb, m); return(XMVector.Select(rgb, clr, XMGlobalConstants.Select1110)); }
public static XMVector RgbToYuv(XMVector rgb) { XMVector scale0 = XMVector.FromFloat(0.299f, -0.147f, 0.615f, 0.0f); XMVector scale1 = XMVector.FromFloat(0.587f, -0.289f, -0.515f, 0.0f); XMVector scale2 = XMVector.FromFloat(0.114f, 0.436f, -0.100f, 0.0f); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(rgb, m); return(XMVector.Select(rgb, clr, XMGlobalConstants.Select1110)); }
public static XMVector XyzToRgb(XMVector xyz) { XMVector scale0 = XMVector.FromFloat(2.3706743f, -0.5138850f, 0.0052982f, 0.0f); XMVector scale1 = XMVector.FromFloat(-0.9000405f, 1.4253036f, -0.0146949f, 0.0f); XMVector scale2 = XMVector.FromFloat(-0.4706338f, 0.0885814f, 1.0093968f, 0.0f); XMVector scale = XMVector.FromFloat(0.17697f, 0.17697f, 0.17697f, 0.0f); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(XMVector.Multiply(xyz, scale), m); return(XMVector.Select(xyz, clr, XMGlobalConstants.Select1110)); }
public static XMVector RgbToXyz(XMVector rgb) { XMVector scale0 = XMVector.FromFloat(0.4887180f, 0.1762044f, 0.0000000f, 0.0f); XMVector scale1 = XMVector.FromFloat(0.3106803f, 0.8129847f, 0.0102048f, 0.0f); XMVector scale2 = XMVector.FromFloat(0.2006017f, 0.0108109f, 0.9897952f, 0.0f); XMVector scale = XMVector.FromFloat(1.0f / 0.17697f, 1.0f / 0.17697f, 1.0f / 0.17697f, 0.0f); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector.Multiply(XMVector3.Transform(rgb, m), scale); return(XMVector.Select(rgb, clr, XMGlobalConstants.Select1110)); }
public static XMVector XyzToSrgb(XMVector xyz) { XMVector scale0 = XMVector.FromFloat(3.2406f, -0.9689f, 0.0557f, 0.0f); XMVector scale1 = XMVector.FromFloat(-1.5372f, 1.8758f, -0.2040f, 0.0f); XMVector scale2 = XMVector.FromFloat(-0.4986f, 0.0415f, 1.0570f, 0.0f); XMVector cutoff = XMVector.FromFloat(0.0031308f, 0.0031308f, 0.0031308f, 0.0f); XMVector exp = XMVector.FromFloat(1.0f / 2.4f, 1.0f / 2.4f, 1.0f / 2.4f, 1.0f); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector lclr = XMVector3.Transform(xyz, m); XMVector sel = XMVector.Greater(lclr, cutoff); // clr = 12.92 * lclr for lclr <= 0.0031308f XMVector smallC = XMVector.Multiply(lclr, XMGlobalConstants.MsrgbScale); // clr = (1+a)*pow(lclr, 1/2.4) - a for lclr > 0.0031308 (where a = 0.055) XMVector largeC = XMVector.Subtract(XMVector.Multiply(XMGlobalConstants.MsrgbA1, XMVector.Pow(lclr, exp)), XMGlobalConstants.MsrgbA); XMVector clr = XMVector.Select(smallC, largeC, sel); return(XMVector.Select(xyz, clr, XMGlobalConstants.Select1110)); }
public static XMVector SrgbToXyz(XMVector srgb) { XMVector scale0 = XMVector.FromFloat(0.4124f, 0.2126f, 0.0193f, 0.0f); XMVector scale1 = XMVector.FromFloat(0.3576f, 0.7152f, 0.1192f, 0.0f); XMVector scale2 = XMVector.FromFloat(0.1805f, 0.0722f, 0.9505f, 0.0f); XMVector cutoff = XMVector.FromFloat(0.04045f, 0.04045f, 0.04045f, 0.0f); XMVector exp = XMVector.FromFloat(2.4f, 2.4f, 2.4f, 1.0f); XMVector sel = XMVector.Greater(srgb, cutoff); // lclr = clr / 12.92 XMVector smallC = XMVector.Divide(srgb, XMGlobalConstants.MsrgbScale); // lclr = pow( (clr + a) / (1+a), 2.4 ) XMVector largeC = XMVector.Pow(XMVector.Divide(XMVector.Add(srgb, XMGlobalConstants.MsrgbA), XMGlobalConstants.MsrgbA1), exp); XMVector lclr = XMVector.Select(smallC, largeC, sel); XMMatrix m = new XMMatrix(scale0, scale1, scale2, XMGlobalConstants.Zero); XMVector clr = XMVector3.Transform(lclr, m); return(XMVector.Select(srgb, clr, XMGlobalConstants.Select1110)); }