// Code for D50 white Ref
 //public static CIEXYZ RGBtoXYZ(int red, int green, int blue)
 //{
 //    // normalize red, green, blue values
 //    double rLinear = (double)red/255.0;
 //    double gLinear = (double)green/255.0;
 //    double bLinear = (double)blue/255.0;
 //    // convert to a sRGB form
 //    double r = (rLinear > 0.04045)? Math.Pow((rLinear + 0.055)/(1 + 0.055), 2.2) : (rLinear/12.92) ;
 //    double g = (gLinear > 0.04045)? Math.Pow((gLinear + 0.055)/(1 + 0.055), 2.2) : (gLinear/12.92) ;
 //    double b = (bLinear > 0.04045)? Math.Pow((bLinear + 0.055)/(1 + 0.055), 2.2) : (bLinear/12.92) ;
 //    // Corrections received by from Rob2412
 //    return new CIEXYZ(
 //        (r * 0.4360747 + g * 0.3850649 + b * 0.1430804),
 //        (r * 0.2225045 + g * 0.7168786 + b * 0.0606169),
 //        (r * 0.0139322 + g * 0.0971045 + b * 0.7141733));
 //}
 /// <summary>
 ///     Converts RGB to CIEXYZ.
 /// </summary>
 public static CIEXYZ RGBtoXYZ(RGB rgb)
 {
     return RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue);
 }
 /// <summary>
 ///     Converts RGB to YUV.
 /// </summary>
 public static YUV RGBtoYUV(RGB rgb)
 {
     return RGBtoYUV(rgb.Red, rgb.Green, rgb.Blue);
 }
 /// <summary>
 ///     Converts RGB to HSL.
 /// </summary>
 public static HSL RGBtoHSL(RGB rgb)
 {
     return RGBtoHSL(rgb.Red, rgb.Green, rgb.Blue);
 }
 /// <summary>
 ///     Converts RGB to CIELab.
 /// </summary>
 public static CIELab RGBtoLab(RGB rgb)
 {
     return XYZtoLab(RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue));
 }
        /// <summary>
        ///     Converts YUV to RGB.
        /// </summary>
        /// <param name="y">Y must be in [0, 1].</param>
        /// <param name="u">U must be in [-0.436, +0.436].</param>
        /// <param name="v">V must be in [-0.615, +0.615].</param>
        public static RGB YUVtoRGB(double y, double u, double v)
        {
            var rgb = new RGB();

            rgb.Red = Convert.ToInt32((y + 1.139837398373983740*v)*255);
            rgb.Green = Convert.ToInt32((y - 0.3946517043589703515*u - 0.5805986066674976801*v)*255);
            rgb.Blue = Convert.ToInt32((y + 2.032110091743119266*u)*255);

            return rgb;
        }
 /// <summary>
 ///     Converts RGB to CMYK
 /// </summary>
 public static CMYK RGBtoCMYK(RGB rgb)
 {
     return RGBtoCMYK(rgb.Red, rgb.Green, rgb.Blue);
 }
 /// <summary>
 ///     Converts RGB to CIELab.
 /// </summary>
 public static CIELab RGBtoLab(RGB rgb)
 {
     return(XYZtoLab(RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue)));
 }
        // Code for D50 white Ref
        //public static CIEXYZ RGBtoXYZ(int red, int green, int blue)
        //{
        //    // normalize red, green, blue values
        //    double rLinear = (double)red/255.0;
        //    double gLinear = (double)green/255.0;
        //    double bLinear = (double)blue/255.0;

        //    // convert to a sRGB form
        //    double r = (rLinear > 0.04045)? Math.Pow((rLinear + 0.055)/(1 + 0.055), 2.2) : (rLinear/12.92) ;
        //    double g = (gLinear > 0.04045)? Math.Pow((gLinear + 0.055)/(1 + 0.055), 2.2) : (gLinear/12.92) ;
        //    double b = (bLinear > 0.04045)? Math.Pow((bLinear + 0.055)/(1 + 0.055), 2.2) : (bLinear/12.92) ;

        //    // Corrections received by from Rob2412
        //    return new CIEXYZ(
        //        (r * 0.4360747 + g * 0.3850649 + b * 0.1430804),
        //        (r * 0.2225045 + g * 0.7168786 + b * 0.0606169),
        //        (r * 0.0139322 + g * 0.0971045 + b * 0.7141733));
        //}
        /// <summary>
        ///     Converts RGB to CIEXYZ.
        /// </summary>
        public static CIEXYZ RGBtoXYZ(RGB rgb)
        {
            return(RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue));
        }
 /// <summary>
 ///     Converts RGB to YUV.
 /// </summary>
 public static YUV RGBtoYUV(RGB rgb)
 {
     return(RGBtoYUV(rgb.Red, rgb.Green, rgb.Blue));
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Converts RGB to CMYK
 /// </summary>
 public static CMYK RGBtoCMYK(RGB rgb)
 {
     return(RGBtoCMYK(rgb.Red, rgb.Green, rgb.Blue));
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     Converts RGB to HSB.
 /// </summary>
 public static HSB RGBtoHSB(RGB rgb)
 {
     return(RGBtoHSB(rgb.Red, rgb.Green, rgb.Blue));
 }