private void EvaluateDigitFromFile() { var openFileDialog = new OpenFileDialog { InitialDirectory = digitsFolder }; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) { digitsFolder = Path.GetDirectoryName(openFileDialog.FileName); Bitmap digitImage = (Bitmap)Image.FromFile(openFileDialog.FileName); digitPictureBox.Image = digitImage; string digitLabel = Path.GetFileNameWithoutExtension(openFileDialog.FileName).First().ToString(); int correctAnswer = int.Parse(digitLabel); InputDigit input = InputDigit.FromImage(correctAnswer, digitImage); double[] normalizedPixels = input.Pixels.Select(p => NormalizeGrayScaleValue(p)).ToArray(); double[] responses = network.Query(normalizedPixels); DisplayAnswer(responses); } }
private void ReadHandwrittenDigit() { Bitmap handwrittenDigit = new Bitmap(writingPanel.Width, writingPanel.Height); writingPanel.DrawToBitmap(handwrittenDigit, new Rectangle(0, 0, writingPanel.Width, writingPanel.Height)); InputDigit input = InputDigit.FromImage(0, handwrittenDigit); double[] normalizedPixels = input.Pixels.Select(p => NormalizeGrayScaleValue(p)).ToArray(); double[] responses = network.Query(normalizedPixels); DisplayAnswer(responses); }