Esempio n. 1
0
        private void btnTestOneSample_Click(object sender, EventArgs e)
        {
            #region OpenDialog
            openFileDialog1.ShowDialog();
            string fn = openFileDialog1.FileName;
            Bitmap B  = PGMUtil.ToBitmap(fn);
            pictureBox1.Image = (Image)B;
            int s = fn.LastIndexOf('\\') + 1;
            #endregion
            if (txtEpochs.Text == "")
            {
                if (RBFFlag)
                {
                    RadialBF = new RBF();
                    LeastMS  = new LMS(Eta, numOfEpochs, MseThreshold, chbxBias.Checked, numOfClusters, RadialBF, true);
                }
                else
                {
                    tryM = new MLP(Eta, numOfEpochs, chbxBias.Checked, new List <int> {
                        4, 4, 4
                    }, true);
                }
                lblAccuracy.Text = "65";
            }

            if (RBFFlag)
            {
                LeastMS.get_sample_test_info(fn.Substring(s).Replace(".pgm", ".pts"));
                lblActualResult.Text = LeastMS.TestingOnePicture();
            }
            else
            {
                tryM.get_sample_test_info(fn.Substring(s).Replace(".pgm", ".pts"));
                lblActualResult.Text = tryM.Testing_Data_Sample();
            }
        }
Esempio n. 2
0
        private void openImg_Click(object sender, EventArgs e)
        {
            try
            {
                string fn = "";
                Bitmap B  = null;

                openFileDialog1.ShowDialog();
                fn = openFileDialog1.FileName;
                B  = PGMUtil.ToBitmap(fn);
                pictureBox1.Size  = B.Size;
                pictureBox1.Image = B;
                //this.Size = B.Size;
                int s = fn.LastIndexOf('\\') + 1;
                int x;
                fn = fn.Replace(@"\\", @"\'");
                if (MethodSelected)
                {
                    if (MLP.NN.TrainingData.Pics.ContainsKey(fn))
                    {
                        x = MLP.TestPoint(MLP.NN.TrainingData.Pics[fn]);
                    }
                    else
                    {
                        x = MLP.TestPoint(MLP.NN.TestingData.Pics[fn]);
                    }

                    outTextBox.Text = Output[x];
                }
                else
                {
                    if (RBF.NN.TrainingData.Pics.ContainsKey(fn))
                    {
                        x = RBF.TestSample(RBF.NN.TrainingData.Pics[fn]);
                    }
                    else
                    {
                        x = RBF.TestSample(RBF.NN.TestingData.Pics[fn]);
                    }

                    outTextBox.Text = Output[x];
                }


                //0 closing close, 1 down minimize, 2 front open, 3 left maximize

                if (x == 1)
                {
                    theProcess.WindowStyle = ProcessWindowStyle.Minimized;
                }
                else if (x == 2)
                {
                    theProcess.WindowStyle = ProcessWindowStyle.Normal;
                }
                else
                {
                    theProcess.WindowStyle = ProcessWindowStyle.Maximized;
                }
                // Retrieve the app's exit code
                Process p = Process.Start(theProcess);
                if (x == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                    p.Kill();
                }
                else
                {
                    p.WaitForExit();
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
            }
        }