Exemple #1
0
        private void Menu_TestNeuralNetwork_Open_Image_Click(object sender, EventArgs e)
        {
            if (OpenImageFile.ShowDialog() == DialogResult.OK)
            {
                double[] InputData = new double[784];
                int      place     = 0;
                string   ImagePath = OpenImageFile.FileName;

                Bitmap img = new Bitmap(ImagePath);
                for (int h = 0; h < img.Height; h++)
                {
                    for (int w = 0; w < img.Width; w++)
                    {
                        Color  pixel      = img.GetPixel(w, h);
                        double brightness = Math.Abs((Math.Floor((((pixel.R + pixel.G + pixel.B) / 3) / 2.55)) / 100) - 1);
                        InputData[place] = brightness;
                        place++;
                    }
                }

                // Image Debug
                ///*
                Bitmap outputImg = new Bitmap(img.Width, img.Height);
                int    i         = 0;
                for (int h = 0; h < img.Height; h++)
                {
                    for (int w = 0; w < img.Width; w++)
                    {
                        if (InputData[i] == 1)
                        {
                            outputImg.SetPixel(w, h, Color.Red);
                        }
                        else if (InputData[i] == 0)
                        {
                            outputImg.SetPixel(w, h, Color.Black);
                        }
                        else
                        {
                            outputImg.SetPixel(w, h, Color.Blue);
                        }
                        i++;
                    }
                }
                outputImg.Save("1.jpg");//*/

                // Calculate
                MessageBox.Show(neural.TestNeuralNetwork(InputData));
                //neural.LearnNeuralNetwork(InputData, "1", 200);
                //MessageBox.Show(neural.TestNeuralNetwork(InputData));
            }
        }
Exemple #2
0
        //open image
        private void stillImageSelectButton_Click(object sender, EventArgs e)
        {
            if (OpenImageFile.ShowDialog() == DialogResult.OK) //if image was selected
            {
                lockSizeToggle.Checked = false;                // unlock the scale lock
                StopAnimationTick();                           //stop any previously running animation

                if (Path.GetExtension(OpenImageFile.FileName) == ".gif")
                {
                    LoadGifFromDisk();
                }
                else
                {
                    LoadStillFromDisk();
                }
            }
        }