# Blood Cell Revolution: Unveiling 11 Distinct Types with Naturalize' Augmentation
## 3 Materials and Methods
### First Data Augmentation \"Naturalize\"  
The pseudocode shown in Algorithm 1 demonstrates the principle behind the \"Naturalize\" augmentation technique and how it works. Figure 4: PBC images containing more than one class. ```
1:# Imports and Paths
2:import os, random, image_processing, SAM_model
3:Define file paths and import essential libraries
4:
5:# Load SAM_model and PBC Dataset
6: mount Google_drive
7:load peripheral blood smear images from PBC dataset
8: SAM = load_model(SAM_model)
9:
10:# Segment PBC Dataset Using SAM
11:segment all PBC images using SAM into segmented \"RBCs, WBCs, PLTs\"
12:save segmented \"RBCs, WBCs, PLTs\" into new datasets on Google_drive
13:
14:# Collision Function
15:function CHECK_collision(positions, x, y, width, height)
16: Function to check for image collisions
17:end function
18:
19:# Composite Image Creation
20:for i in range(num_images) do
21: Load background image and initialize positions list
22: Add 1 WBC image
23: Add 8 RBC images with collision avoidance
24: Save the composite image on Google_drive
25:endfor
```  
**Algorithm 1** Naturalize Algorithm  
The \"Naturalize\" augmentation technique consists of two primary steps:  
* Step 1--Segmentation: A portion of the initial PBC dataset images underwent segmentation and were separated into six distinct datasets employing the \"Segment Anything Model (SAM)\" developed by Meta AI [29]. These datasets encompass segmented images of Red Blood Cells (RBC), Banded Neutroph (BNE), Meta-myelocytes (MMY), Myelocytes (MY), Pro-myelocytes (PMY), and Segmented Neutroph (SNE). This selective approach, using only these six classes in SAM, was adopted based on the findings of our earlier Exploratory Data Analysis (EDA) and classification report, which demonstrated an overall enhancement in classification performance, contrasting with the use of all 11 classes. Notably, for each cell class, SAM generates masks that partition the images into three distinct components: background, segmented RBCs, and segmented WBCs. To offer further clarification, Figure 5 utilizes Pro-myelocytes (PMY) as a demonstration of the SAM model's application. This figure showcases the segmentation process for PMY images, illustrating the division into background, segmented RBCs, and segmented PMYs. * Step 2--Generating Composite Images (Figure 6): The SAM-segmented RBCs were combined with randomly selected WBCs from the \"BNE, MMY, MY, PMY, and SNE\" datasets to create composite images. The primary objective in this selection and fusion of segmented RBCs and WBCs is to generate entirely distinct images each time the Naturalize code is run. Converting the segmented cells into the RGBA format is aimed at resetting the alpha transparency channel within these segments, preventing their black backgrounds from appearing in the newly generated images using the Naturalize method. However, the size of segmented RBCs and WBCs remains unchanged to mirror the real dimensions of blood cells in peripheral blood smears. Determining the size (width and height) of the segmented RBCs and WBCs functions as input for the Collision-Free mechanism, ensuring that the segmented RBC images avoid overlapping or excessive stacking on either themselves or the segmented WBC  
Figure 5: The “Naturalize” first step—segmentation. images when added to the background image. This function's output results in well-organized peripheral blood cell images without cells accumulating on top of each other. This procedural demonstration is depicted in Figures 5 and 6, highlighting the creation of composite PMY images as an illustrative example. Figure 6: The “Naturalize” second step—composite image generation. Informed by our comprehensive exploratory data analysis (EDA), we have carefully curated specific images across multiple classes, underscoring our dedication to maintaining data quality.