Пример #1
0
        private void button_CPP_Monotonic_Cubic_Spline_Interpolation_Click(object sender, EventArgs e)
        {
            GrayVdataDictionary.getInstance().Updata_Vdata_Gray_DataSet();
            double[] grays    = new double[DP213_Static.Max_Gray_Amount];
            double[] voltages = new double[DP213_Static.Max_Gray_Amount];

            int    count       = 0;
            double max_voltage = Double.MinValue;
            double min_voltage = Double.MaxValue;

            foreach (KeyValuePair <int, double> keyValue in GrayVdataDictionary.getInstance().keyValuePairs)
            {
                grays[count]    = keyValue.Key;
                voltages[count] = keyValue.Value;

                if (max_voltage < voltages[count])
                {
                    max_voltage = voltages[count];
                }

                if (min_voltage > voltages[count])
                {
                    min_voltage = voltages[count];
                }

                count++;
            }
            if (radioButton_Voltage_to_Gray.Checked)
            {
                IntPtr   temp = CreateMonotoneCubicSpline(voltages.Length, grays.Length, voltages, grays);
                double[] mM   = new double[voltages.Length];
                Marshal.Copy(temp, mM, 0, mM.Length);

                for (double voltage = min_voltage; voltage <= max_voltage; voltage += 0.001)
                {
                    double gray = interpolate(voltages.Length, grays.Length, voltages, grays, mM, voltage);
                    chart1.Series["Vdata_Gray_Points"].Points.AddXY(gray, voltage);
                    chart1.Series["Vdata_Gray_Points"].Points[pointIndex++].Color = Color.FromArgb(100, 100, 200);
                }
            }
            else if (radioButton_Gray_to_Voltage.Checked)
            {
                Array.Reverse(grays);
                Array.Reverse(voltages);

                IntPtr   temp = CreateMonotoneCubicSpline(grays.Length, voltages.Length, grays, voltages);
                double[] mM   = new double[grays.Length];
                Marshal.Copy(temp, mM, 0, mM.Length);

                for (int gray = 0; gray <= 255; gray++)
                {
                    double voltage = interpolate(grays.Length, voltages.Length, grays, voltages, mM, gray);
                    chart1.Series["Vdata_Gray_Points"].Points.AddXY(gray, voltage);
                    chart1.Series["Vdata_Gray_Points"].Points[pointIndex++].Color = Color.FromArgb(200, 100, 100);
                }
            }
        }
Пример #2
0
        private void button_display_point_data_Click(object sender, EventArgs e)
        {
            GrayVdataDictionary.getInstance().Updata_Vdata_Gray_DataSet();

            foreach (KeyValuePair <int, double> keyValue in GrayVdataDictionary.getInstance().keyValuePairs)
            {
                chart1.Series["Vdata_Gray_Points"].Points.AddXY(keyValue.Key, keyValue.Value);
                chart1.Series["Vdata_Gray_Points"].Points[pointIndex++].Color = GrayVdataDictionary.getInstance().Get_Color();
            }
        }
Пример #3
0
        private void button_Csharp_Polynomial_Interpolation_Click(object sender, EventArgs e)
        {
            Poly_Interpolation poly_Interpolation = new Poly_Interpolation();

            GrayVdataDictionary.getInstance().Updata_Vdata_Gray_DataSet();
            int[]    grays    = new int[DP213_Static.Max_Gray_Amount];
            double[] voltages = new double[DP213_Static.Max_Gray_Amount];

            int    count       = 0;
            double max_voltage = Double.MinValue;
            double min_voltage = Double.MaxValue;

            foreach (KeyValuePair <int, double> keyValue in GrayVdataDictionary.getInstance().keyValuePairs)
            {
                grays[count]    = keyValue.Key;
                voltages[count] = keyValue.Value;


                if (max_voltage < voltages[count])
                {
                    max_voltage = voltages[count];
                }

                if (min_voltage > voltages[count])
                {
                    min_voltage = voltages[count];
                }

                count++;
            }
            if (radioButton_Voltage_to_Gray.Checked)
            {
                poly_Interpolation.Update_Function_Param(grays, voltages);
                for (double voltage = min_voltage; voltage <= max_voltage; voltage += 0.001)
                {
                    int gray = poly_Interpolation.Polynorminal_Fuction(voltage);
                    chart1.Series["Vdata_Gray_Points"].Points.AddXY(gray, voltage);
                    chart1.Series["Vdata_Gray_Points"].Points[pointIndex++].Color = Color.FromArgb(150, 150, 0);
                }
            }
            else if (radioButton_Gray_to_Voltage.Checked)
            {
                poly_Interpolation.Update_Function_Param2(grays, voltages);
                for (int gray = 0; gray <= 255; gray++)
                {
                    double voltage = poly_Interpolation.Polynorminal_Fuction2(gray);
                    chart1.Series["Vdata_Gray_Points"].Points.AddXY(gray, voltage);
                    chart1.Series["Vdata_Gray_Points"].Points[pointIndex++].Color = Color.FromArgb(0, 150, 150);
                }
            }
        }