Esempio n. 1
0
        protected bool Get_Initial_RVreg1B_Using_LUT_MCI(Gamma_Set Set, int band, OC_Mode Mode)
        {
            if ((band >= 1) && (band <= DP213_Static.Max_HBM_and_Normal_Band_Amount) && (vars.Target.double_Lv > Algorism_Lower_Skip_LV) && (vars.Target.double_Lv < Algorism_Upper_Skip_LV))
            {
                f1().GB_Status_AppendText_Nextline("Before) R/G/B/Vreg1 = " + vars.Gamma.int_R.ToString() + "/" + vars.Gamma.int_G.ToString().ToString() + "/" + vars.Gamma.int_B.ToString() + "/" + vars.Vreg1, Color.Blue);

                int        gray = 0;
                RGB_Double Gray = DP213_Main_OC_Flow.init_gray_lut.Get_LUT_RGB(band, gray, Mode);

                RGB_Double Gamma_Voltage = new RGB_Double();
                Gamma_Voltage.double_R = InterpolationFomulaFactory.GetPrevBand_Red_Volatge(Gray.double_R);
                Gamma_Voltage.double_G = InterpolationFomulaFactory.GetPrevBand_Green_Volatge(Gray.double_G);
                Gamma_Voltage.double_B = InterpolationFomulaFactory.GetPrevBand_Blue_Volatge(Gray.double_B);

                double Voltage_VREF0    = storage.Get_Voltage_VREF0();
                double Voltage_VREF4095 = storage.Get_Voltage_VREF4095();
                double Vreg1_voltage    = Voltage_VREF4095 + ((Gamma_Voltage.double_G - Voltage_VREF4095) * (900.0 / (storage.Get_All_band_gray_Gamma(Set, (band - 1), gray).int_G + 389.0))); //just use HBM_Gamma[0], because other normal band copy G255 R/G/B From HBM

                vars.Vreg1       = Imported_my_cpp_dll.DP213_Get_Vreg1_Dec(Voltage_VREF4095, Voltage_VREF0, Vreg1_voltage);
                vars.Gamma.int_R = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Dec(Voltage_VREF4095, Vreg1_voltage, Gamma_Voltage.double_R);
                vars.Gamma.int_B = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Dec(Voltage_VREF4095, Vreg1_voltage, Gamma_Voltage.double_B);

                f1().GB_Status_AppendText_Nextline("After C++) R/G/B/Vreg1 = " + vars.Gamma.int_R.ToString() + "/" + vars.Gamma.int_G.ToString().ToString() + "/" + vars.Gamma.int_B.ToString() + "/" + vars.Vreg1, Color.Red);
                init_algorithm_storage_cpp.Set_All_band_gray_Gamma(Set, band, gray, vars.Gamma);

                return(true);
            }
            else
            {
                f1().GB_Status_AppendText_Nextline("Skip)Get_Initial_RVreg1B_Using_LUT_MCI()", Color.DarkRed);
                return(false);
            }
        }
Esempio n. 2
0
        public static void C_Sharp_DP213_Gray255_Get_Intial_R_Vreg1_B_Using_Previous_Band_Method(double Prev_Band_Voltage_AM1_R, double Prev_Band_Voltage_AM1_G, double Prev_Band_Voltage_AM1_B, ref int Vreg1_Dec_Init, ref int Gamma_R, ref int Gamma_B,
                                                                                                 bool[] Selected_Band, int[] Previous_Band_Gamma_Red, int[] Previous_Band_Gamma_Green, int[] Previous_Band_Gamma_Blue, int band, double band_Target_Lv, int Previous_Band_Vreg1_Dec
                                                                                                 , double[] Previous_Band_Finally_Measured_Lv, double Voltage_VREF4095, double Voltage_VREF0)
        {
            Form1 f1 = (Form1)Application.OpenForms["Form1"];

            if (band >= 1 && Selected_Band[band] == true)
            {
                SJH_Matrix M = new SJH_Matrix();
                double[]   Previous_Band_Gamma_Red_Voltage   = Get_Previous_Band_Gamma_Voltage(Prev_Band_Voltage_AM1_R, Previous_Band_Vreg1_Dec, Previous_Band_Gamma_Red, Voltage_VREF4095, Voltage_VREF0);
                double[]   Previous_Band_Gamma_Green_Voltage = Get_Previous_Band_Gamma_Voltage(Prev_Band_Voltage_AM1_G, Previous_Band_Vreg1_Dec, Previous_Band_Gamma_Green, Voltage_VREF4095, Voltage_VREF0);
                double[]   Previous_Band_Gamma_Blue_Voltage  = Get_Previous_Band_Gamma_Voltage(Prev_Band_Voltage_AM1_B, Previous_Band_Vreg1_Dec, Previous_Band_Gamma_Blue, Voltage_VREF4095, Voltage_VREF0);

                double[][] A_R = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);
                double[][] A_G = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);
                double[][] A_B = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);

                //Get A[i][count] = Previous_Band_Gamma_Green_Voltage[i]^j
                int count = 0;
                for (int i = 0; i <= (DP213_Static.Max_Gray_Amount - 1); i++)
                {
                    count = 0;
                    for (int j = (DP213_Static.Max_Gray_Amount - 1); j >= 0; j--)
                    {
                        A_R[i][count] = Math.Pow(Previous_Band_Gamma_Red_Voltage[i], j);
                        A_G[i][count] = Math.Pow(Previous_Band_Gamma_Green_Voltage[i], j);
                        A_B[i][count] = Math.Pow(Previous_Band_Gamma_Blue_Voltage[i], j);
                        count++;
                    }
                }

                //Get C[DP213_Static.Max_Gray_Amount] = inv(A)[DP213_Static.Max_Gray_Amount,DP213_Static.Max_Gray_Amount] * Previous_Band_Target_Lv[DP213_Static.Max_Gray_Amount]
                double[][] Inv_A_R = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);
                double[][] Inv_A_G = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);
                double[][] Inv_A_B = M.MatrixCreate(DP213_Static.Max_Gray_Amount, DP213_Static.Max_Gray_Amount);
                double[]   C_R     = new double[DP213_Static.Max_Gray_Amount];
                double[]   C_G     = new double[DP213_Static.Max_Gray_Amount];
                double[]   C_B     = new double[DP213_Static.Max_Gray_Amount];
                Inv_A_R = M.MatrixInverse(A_R);
                Inv_A_G = M.MatrixInverse(A_G);
                Inv_A_B = M.MatrixInverse(A_B);
                C_R     = M.Matrix_Multiply(Inv_A_R, Previous_Band_Finally_Measured_Lv);
                C_G     = M.Matrix_Multiply(Inv_A_G, Previous_Band_Finally_Measured_Lv);
                C_B     = M.Matrix_Multiply(Inv_A_B, Previous_Band_Finally_Measured_Lv);

                //Show "C10*(Vdata^10) + C9*(Vdata^9) + C8*(Vdata^8) + C7*(Vdata^7) + C6*(Vdata^6) + .... + C1*Vdata + C0 = Lv"
                double Target_Lv              = band_Target_Lv;
                double Calculated_Vdata_Red   = 0;
                double Calculated_Vdata_Green = 0;
                double Calculated_Vdata_Blue  = 0;
                double Calculated_Target_Lv   = 0;
                int    iteration;

                //Get Vreg1 From Gamma_Green (Or the "Actual_Previous_Vdata_Green" can directly get from the datagridview_voltage_table
                //Didn't get data directly from the datagridview_voltage_table, because it's gonna be easier to code in cpp dll
                double Previous_Band_Vreg1_Voltage = Imported_my_cpp_dll.DP213_Get_Vreg1_Voltage(Voltage_VREF4095, Voltage_VREF0, Previous_Band_Vreg1_Dec);
                double Actual_Previous_Vdata_Red   = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Voltage(Voltage_VREF4095, Previous_Band_Vreg1_Voltage, Previous_Band_Gamma_Red[0]);
                double Actual_Previous_Vdata_Green = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Voltage(Voltage_VREF4095, Previous_Band_Vreg1_Voltage, Previous_Band_Gamma_Green[0]);
                double Actual_Previous_Vdata_Blue  = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Voltage(Voltage_VREF4095, Previous_Band_Vreg1_Voltage, Previous_Band_Gamma_Blue[0]);

                //Red
                for (double Vdata = Actual_Previous_Vdata_Red; Vdata <= Voltage_VREF4095; Vdata += 0.001)
                {
                    Calculated_Target_Lv = 0;
                    iteration            = 0;
                    for (int j = (DP213_Static.Max_Gray_Amount - 1); j >= 0; j--)
                    {
                        Calculated_Target_Lv += (Math.Pow(Vdata, j) * C_R[iteration++]);
                    }
                    if ((Calculated_Target_Lv < Target_Lv) && Calculated_Vdata_Red == 0)
                    {
                        Calculated_Vdata_Red = Vdata;
                        break;
                    }
                }

                //Green
                for (double Vdata = Actual_Previous_Vdata_Green; Vdata <= Voltage_VREF4095; Vdata += 0.001)
                {
                    Calculated_Target_Lv = 0;
                    iteration            = 0;
                    for (int j = (DP213_Static.Max_Gray_Amount - 1); j >= 0; j--)
                    {
                        Calculated_Target_Lv += (Math.Pow(Vdata, j) * C_G[iteration++]);
                    }

                    if ((Calculated_Target_Lv < Target_Lv) && Calculated_Vdata_Green == 0)
                    {
                        Calculated_Vdata_Green = Vdata;
                        break;
                    }
                }

                //Blue
                for (double Vdata = Actual_Previous_Vdata_Blue; Vdata <= Voltage_VREF4095; Vdata += 0.001)
                {
                    Calculated_Target_Lv = 0;
                    iteration            = 0;
                    for (int j = (DP213_Static.Max_Gray_Amount - 1); j >= 0; j--)
                    {
                        Calculated_Target_Lv += (Math.Pow(Vdata, j) * C_B[iteration++]);
                    }
                    if ((Calculated_Target_Lv < Target_Lv) && Calculated_Vdata_Blue == 0)
                    {
                        Calculated_Vdata_Blue = Vdata;
                        break;
                    }
                }

                f1.GB_Status_AppendText_Nextline("RBVreg1 Algorithm)Calculated_Vdata_Red/Calculated_Vdata_Green/Calculated_Vdata_Blue : "
                                                 + Calculated_Vdata_Red.ToString() + "/" + Calculated_Vdata_Green.ToString() + "/" + Calculated_Vdata_Blue.ToString(), Color.Blue);

                double Calculated_Vreg1_voltage = Voltage_VREF4095 + ((Calculated_Vdata_Green - Voltage_VREF4095) * (900.0 / (Previous_Band_Gamma_Green[0] + 389.0))); //just use HBM_Gamma[0], because other normal band copy G255 R/G/B From HBM
                Vreg1_Dec_Init = Imported_my_cpp_dll.DP213_Get_Vreg1_Dec(Voltage_VREF4095, Voltage_VREF0, Calculated_Vreg1_voltage);

                f1.GB_Status_AppendText_Nextline("RBVreg1 Algorithm)Calculated_Vreg1_voltage : " + Calculated_Vreg1_voltage.ToString(), Color.Blue);

                //Got the Vreg1
                //Need to get Gamma_R/B
                Gamma_R = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Dec(Voltage_VREF4095, Calculated_Vreg1_voltage, Calculated_Vdata_Red);
                Gamma_B = Imported_my_cpp_dll.DP213_Get_AM2_Gamma_Dec(Voltage_VREF4095, Calculated_Vreg1_voltage, Calculated_Vdata_Blue);

                DP213_If_One_Of_RGB_Near_Register_Min_Max_Set_Gamma_As_Prev_Band_Gamma(ref Gamma_R, ref Previous_Band_Gamma_Blue[0], ref Gamma_B, Previous_Band_Gamma_Red[0], Previous_Band_Gamma_Green[0], Previous_Band_Gamma_Blue[0]);
            }
            else //Band0 + Other not selected Bands's
            {
                //Do nothing
            }
        }