Skip to main content
. 2023 Jul 19;23(14):6533. doi: 10.3390/s23146533
Algorithm 1: AugmentTrainSet(img, iteration, augmented_images)
//Augment train images from an original image
Input
(1) img: Original image in RGB channel
(2) iteration: The number of iterations to perform
Output
(3) augmented_images: List of augmented images
Begin
1.   augmented_imagesemptylist
2.   nheightofimg
3.   mwidthofimg
4.   For i=1 toiteration do
5.   imgcopied  copy of img
6.   randflip random integer in the range 1 to 1
7.   randred, randgreen, randblue  random integer in the range 10 to 10
8.   If randflip is 1 then
9.   imgcopiedimgni,mj for all i in 1 to n and j in 1 to m
10. Else if randflip is 0 then
11. imgcopiedimgi,mj for all i in 1 to n and j in 1 to m
12. Else if randflip is 1 then
13. imgcopiedimgni,j for all i in 1 to n and j in 1 to m
14. For each pixel p in red channel of imgcopied
15. pclip(p+randred, 0, 255)
16. End for
17. For each pixel p in green channel of imgcopied
18. pclip(p+randgreen, 0, 255)
19. End for
20. For each pixel p in blue channel of imgcopied
21. pclip(p+randblue, 0, 255)
22. End for
23. augmented_images.append(imgcopied)
24. End for
25. Return augmented_images
END