public static double[][] TransformationMatrix(ColorSpace colorSpace, doublePoint whitePoint)
        {
            double[][] value = new double[3][];
            value[0] = new double[3] {
                colorSpace.Red.X, colorSpace.Green.X, colorSpace.Blue.X
            };
            value[1] = new double[3] {
                colorSpace.Red.Y, colorSpace.Green.Y, colorSpace.Blue.Y
            };
            value[2] = new double[3];
            for (int i = 0; i < 3; i++)
            {
                value[2][i] = 1 - value[1][i] - value[0][i];
            }

            double[][] WPvector = new double[3][];
            WPvector[0] = new double[1] {
                whitePoint.X / whitePoint.Y
            };
            WPvector[1] = new double[1] {
                1
            };
            WPvector[2] = new double[1] {
                (1 - whitePoint.X - whitePoint.Y) / whitePoint.Y
            };

            double[][] result = MatrixCalculations.MatrixProduct((MatrixCalculations.MatrixInverse(value)), WPvector);
            double[][] temp   = MatrixCalculations.MatrixCreate(3, 3);
            for (int i = 0; i < 3; i++)
            {
                temp[i][i] = result[i][0];
            }
            result = MatrixCalculations.MatrixProduct(value, temp);
            return(result);
        }
示例#2
0
 public Form1()
 {
     GObjects = new GlobalObjects();
     InitializeComponent();
     GObjects.finished = true;
     SeparationOption_Combo.SelectedIndex = 0;
     Illuminant_Combo.Items.AddRange(GObjects.IlluminnatsNames);
     ColorSpace_Combo.Items.AddRange(GObjects.ColorSpaceNames);
     ColorSpace_Combo.SelectedIndex = 0;
     GObjects.sRGB2XYZs             = ImageControl.TransformationMatrix(GObjects.ColorSpaceValues[0], GObjects.IlluminantsValues[5]);
     GObjects.XYZ2sRGB = MatrixCalculations.MatrixInverse(GObjects.sRGB2XYZs);
     //spytac o LAB
 }