public List <MnistEntry> DataAugmentation(List <MnistEntry> train_images) { List <MnistEntry> new_images = new List <MnistEntry>(); Random rnd = new Random(); for (int i = 0; i <= train_images.Count - 1; i++) { MnistEntry mnistEntry = train_images[i]; Image img = byteArrayToImage(mnistEntry.Image); //Translation only Bitmap newImage = TranslateImage(img, 1, 0); AddNewImage(new_images, newImage, mnistEntry.Label); Bitmap newImage2 = TranslateImage(img, -1, 0); AddNewImage(new_images, newImage2, mnistEntry.Label); Bitmap newImage3 = TranslateImage(img, 0, 1); AddNewImage(new_images, newImage3, mnistEntry.Label); Bitmap newImage4 = TranslateImage(img, 0, -1); AddNewImage(new_images, newImage4, mnistEntry.Label); //Program.ShowImageVisualizer(byteArrayToImage(newImage), img); } train_images.AddRange(new_images); return(train_images); }
void AddNewImage(List <MnistEntry> new_images, Bitmap newImage, int label) { MnistEntry mnistNewEntry = new MnistEntry(); mnistNewEntry.Image = ToByteArray(newImage); mnistNewEntry.Label = label; new_images.Add(mnistNewEntry); }