Skip to main content
. 2025 Sep 9;11(9):309. doi: 10.3390/jimaging11090309
Algorithm 1. Pseudocode of the RBC single-cell extraction and resizing technique
RBC_Extraction(image_path, output_dir)
  load image from image_path
  apply mean-shift filtering to image  → shifted
  convert shifted image to grayscale  → gray
  apply Otsu thresholding to gray   → thresh
  find contours from thresh      → cnts
  for each contour c in cnts do
    crop image and mask around contour → image_crop, mask_crop
    if mask_crop is valid then
      check if cell touches border:
        if true:
          save touching cell to “touching” folder
        else:
          extract RBC from mask
          determine RBC size:
          if size ≤ 16 px: overlay to 32 × 32 and save as “small”
          else if size ≤ 32 px: overlay to 32 × 32 and save as “32 size”
          else if size ≤ 128 px: overlay to 128 × 128 and save as “128 size”
          else if size ≤ 256 px: overlay to 256 × 256 and save as “256 size”
          else if size ≤ 512 px: overlay to 512 × 512 and save as “512 size”
          else if size ≤ 1024 px: overlay to 1024 × 1024 and save as “1024 size”
          else: save as “oversize”
    else:
  end for
  save processing results (original, filtered, gray, mask, contours)
  return RBC_dataset_summary