Пример #1
0
        public void openIMage()
        {
            Show_Image SI = new Show_Image();

            SI.ShowDialog();
            loadimage KM = new loadimage(SI.loodim);
            Process   currentProcess1 = System.Diagnostics.Process.GetCurrentProcess();

            long totalBytesOfMemoryUsed2 = currentProcess1.WorkingSet64;

            Benchmark.Start();
            double[] res = this.S_V_M.testing(KM);
            string   output_to_Messagebox = "the output is ";

            string[] f = this.RI.classes.ToArray();
            Voting(KM.LM, res, null, KM.classes);
            double maxf = res.Max();

            //int indexk = 0;
            //for (int d = 0; d < res.Length; d++)
            //{
            //    if (res[d] >= maxf)
            //        indexk = d;
            //}
            //output_to_Messagebox = f[indexk];
            for (int d = 0; d < res.Length; d++)
            {
                if (res[d] > 3)
                {
                    output_to_Messagebox += " " + f[d];
                }
            }

            Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

            long totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

            Benchmark.End();
            this.testingtime.Text = "The Testing Time : " + Benchmark.GetSeconds().ToString();
            this.overall_accuracy_control.Text = this.overall_accuracy.ToString();
            label2.Text = "Testing Memory is " + Math.Abs(totalBytesOfMemoryUsed - totalBytesOfMemoryUsed2) + " Bytes";
            MessageBox.Show(output_to_Messagebox);
            Showdrawing SD = new Showdrawing();

            SD.IM.Image = pic_after_drow;
            SD.Show();
        }
Пример #2
0
        public SVM_handler(ReadImages RM2, DataGridView confusion_matrix_control, TextBox overall_accuracy_control, Label trainingtime, Label testingtime, Label l1, Label L2)
        {
            RI = RM2;
            confusion_matrix = new int[1, this.RI.classes.Count];
            for (int f = 0; f < 1; f++)
            {
                for (int x = 0; x < this.RI.classes.Count; x++)
                {
                    confusion_matrix[f, x] = 0;
                }
            }
            this.confusion_matrix_control = confusion_matrix_control;
            this.trainingtime             = trainingtime;
            this.testingtime = testingtime;
            this.overall_accuracy_control = overall_accuracy_control;
            Label1 = l1;
            label2 = L2;
            Process currentProcess         = System.Diagnostics.Process.GetCurrentProcess();
            long    totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

            Benchmark.Start();
            S_V_M = new Support_Vector_Machine(RI);
            Benchmark.End();
            this.trainingtime.Text = " The Training Time : " + Benchmark.GetSeconds().ToString();
            Process currentProcess1 = System.Diagnostics.Process.GetCurrentProcess();

            long totalBytesOfMemoryUsed1 = currentProcess1.WorkingSet64;

            Label1.Text = "The Training Memmory is " + Math.Abs(totalBytesOfMemoryUsed - totalBytesOfMemoryUsed1) + " bytes";

            for (int d = 0; d < this.RI.TestingImages.Length; ++d)
            {
                LM = new loadimage(RI.TestingImages[d]);
                Voting(LM.LM, S_V_M.testing(LM), confusion_matrix, this.LM.classes);
            }

            display_results(this.confusion_matrix_control, this.overall_accuracy_control);
            MessageBox.Show("Done Testing");
        }
Пример #3
0
        public double[] testing(loadimage InputSample)
        {
            double[] output;
            float    response = 0;

            output = new double[this.DAtaset.classes.Count];
            for (int trainindex = 0; trainindex < InputSample.image.Count; trainindex++)
            {
                for (int p1 = 0; p1 < DAtaset.TrainingSamples[0].Feature.Descriptor.Length; ++p1)
                {
                    sample.Data[0, p1] = (InputSample.image[trainindex].Feature.Descriptor[p1]);
                }
                response = model.Predict(sample);
                ++output[Convert.ToInt32(response) - 1];
                // mm[Convert.ToInt32(response) - 1].Add(InputSample.image[trainindex].Feature.KeyPoint.Point);
                float x     = InputSample.image[trainindex].Feature.KeyPoint.Point.X;
                float y     = InputSample.image[trainindex].Feature.KeyPoint.Point.Y;
                float index = response;
                mm[Convert.ToInt32(response) - 1].Add(new Point(Convert.ToInt32(x), Convert.ToInt32(y)));
            }
            return(output);
        }
        public void Run()
        {
            confusion_matrix = new int[1, this.ReadIm.classes.Count];
            for (int f = 0; f < 1; f++)
            {
                for (int x = 0; x < this.ReadIm.classes.Count; x++)
                {
                    confusion_matrix[f, x] = 0;
                }
            }

            int[] w = GetNumberOfNeurins();
            ML = new MultiLayerPerceptron(ReadIm, Eta, Epochs, NumberOfHiddenLayers, w);
            Process currentProcess         = System.Diagnostics.Process.GetCurrentProcess();
            long    totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

            Benchmark.Start();
            ML.MLPTraining();
            Benchmark.End();
            Process currentProcess1         = System.Diagnostics.Process.GetCurrentProcess();
            long    totalBytesOfMemoryUsed2 = currentProcess1.WorkingSet64;

            Label1.Text            = "The Training Memory is " + Math.Abs(totalBytesOfMemoryUsed2 - totalBytesOfMemoryUsed) + " Bytes";
            this.trainingtime.Text = "The Training time : " + Benchmark.GetSeconds().ToString();
            double[]  output = new double[ReadIm.classes.Count];
            loadimage LMR;

            for (int c = 0; c < this.ReadIm.TestingImages.Length; c++)
            {
                LMR    = new loadimage(this.ReadIm.TestingImages[c]);
                output = ML.MLPTesting(LMR);
                Voting(LMR.LM, output, confusion_matrix, LMR.classes);
            }

            display_results(confusion_matrix_control, overall_accuracy_control);
            overall_accuracy_control.Text = (((this.number_of_rigth_samples) / (double)(this.numberallsamplesinaccurcy)) * 100).ToString() + " %";
            MessageBox.Show("Done Testing");
        }
        public void openimage()
        {
            Show_Image SI = new Show_Image();

            SI.ShowDialog();
            loadimage KM = new loadimage(SI.loodim);
            Process   currentProcess1 = System.Diagnostics.Process.GetCurrentProcess();

            long totalBytesOfMemoryUsed2 = currentProcess1.WorkingSet64;

            Benchmark.Start();
            double[] res = this.ML.MLPTesting(KM);
            string   output_to_Messagebox = "the output is ";

            string[] f = this.ReadIm.classes.ToArray();
            Voting(KM.LM, res, null, KM.classes);
            for (int d = 0; d < res.Length; d++)
            {
                if (res[d] > 30)
                {
                    output_to_Messagebox += " " + f[d];
                }
            }
            Benchmark.End();
            Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

            long totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

            Label2.Text = "The Testing Memory is " + Math.Abs(totalBytesOfMemoryUsed - totalBytesOfMemoryUsed2) + " Bytes";

            this.testingtime.Text = "The Testing Time : " + Benchmark.GetSeconds().ToString();
            MessageBox.Show(output_to_Messagebox);
            Showdrawing SD = new Showdrawing();

            SD.IM.Image = pic_after_drow;
            SD.Show();
        }
        public double[] MLPTesting(loadimage InputSample)
        {
            double[] result = new double[this.Dataset.classes.Count];
            double[] x      = new double[AllLayers[AllLayers.Length - 1].Neurons.Length];
            for (int g = 0; g < InputSample.image.Count; g++)
            {
                //for (int index = 0; index < InputSample.image[g].Feature.Descriptor.Length; index++)
                //{
                //    InputSample.image[g].Feature.Descriptor[index] =
                //        (InputSample.image[g].Feature.Descriptor[index] - Dataset.Mean[index]) / Dataset.Max[index];
                //}

                AllLayers[0].SetY(InputSample.image[g].Feature.Descriptor);

                ///forward finished
                for (int L = 1; L < AllLayers.Length; ++L)
                {
                    AllLayers[L].Forward(AllLayers[L - 1]);
                }

                for (int i = 0; i < AllLayers[AllLayers.Length - 1].Neurons.Length; i++)
                {
                    x[i] = AllLayers[AllLayers.Length - 1].Neurons[i].Y;
                }

                float x1 = InputSample.image[g].Feature.KeyPoint.Point.X;
                float y1 = InputSample.image[g].Feature.KeyPoint.Point.Y;

                int gs = (Convert.ToInt32(des(x)) - 1);

                mm[gs].Add(new Point(Convert.ToInt32(x1), Convert.ToInt32(y1)));

                result[des(x)]++;
            }
            return(result);
        }