Skip to main content
. 2025 Sep 9;11(9):309. doi: 10.3390/jimaging11090309
Algorithm 5. Automated data augmentation and centering for RBC image dataset
Auto_Data_Augmentation(data_list, image_path)
  for each folder in data_list do
    define folder_path
    if folder_path exists then
      for each image_file in folder_path do
        load image
        for each scale_factor in [0.98, 0.99, 1.00, 1.01] do
          resize image while embedding onto black background
          save augmented image
          for each rotation angle based on num_rotations do
            rotate resized image
            for each flip_code in [0, 1, −1] do
              flip rotated image (vertical, horizontal, both)
    else: Print warning (folder not found)
  end for
  for each folder in data_list do
    define folder_aug
    for each image_file in folder_aug do
      load augmented image   → image
      apply mean-shift filtering  → shifted
      convert to grayscale and apply Otsu thresholding → thresh
      detect contours → cnts
      for each contour c in cnts do
        extract ROI with small padding
        generate binary mask and apply bitwise extraction
        if extracted cell size < 128×128:
          embed cell into black 128×128 background, centered
          save centered image
  end for generate augmentation report summarizing transformations applied
  return augmented_dataset_summary