Beispiel #1
0
        public void Parse()
        {
            foreach (string filePath in Directory.GetFiles(path))
            {
                int    digit      = int.Parse(Path.GetFileName(filePath)[0].ToString());
                Bitmap bitmap     = new Bitmap(filePath);
                var    digitImage = new DigitImage();
                digitImage.Digit  = digit;
                digitImage.Width  = bitmap.Width;
                digitImage.Height = bitmap.Height;

                for (int y = 0; y < bitmap.Height; y++)
                {
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        Color color = bitmap.GetPixel(x, y);
                        digitImage.Pixels.Add(1 - color.GetBrightness());
                    }
                }

                DigitImages.Add(digitImage);
            }

            DigitImages.Shuffle();
            originalCount = DigitImages.Count;
        }
Beispiel #2
0
        private void AddDisturbance(List <DigitImage> dataSet, float probability = 0.1f, float maxDifference = 1)
        {
            int count = dataSet.Count;

            for (int i = 0; i < count; i++)
            {
                var imageCopy = new DigitImage(dataSet[i]);
                imageCopy.Disturb(probability, maxDifference, random);
                dataSet.Add(imageCopy);
            }
        }
Beispiel #3
0
 public DigitImage(DigitImage digitImage)
 {
     this.Digit = digitImage.Digit;
     this.Pixels.AddRange(digitImage.Pixels);
 }