Image Augmentor: An Image Data Augmentation Plugin for Deep Learning and Computer Vision using ImageJ
The provided Java code implements an ImageJ plugin called "ImageAugmentor" designed for image augmentation, a technique commonly used in deep learning for data diversification. The plugin, presented as a generic dialog, enables users to select input and output directories, set augmentation parameters such as the number of generated images, and apply various image transformation methods. These methods include random flipping, scaling, rotation, noise addition, exponential transformation, gamma correction, contrast adjustment, brightness modification, smoothing, sharpening, and Gaussian distortion. The plugin leverages ImageJ's functionalities to process images based on user-defined augmentation probabilities. The resulting augmented images are saved in the chosen output format (e.g., PNG, JPG). The code is well-commented and structured, making it suitable for integration into image analysis workflows and potentially serving as a useful tool for researchers working with image datasets in the field of machine learning and computer vision.
sudo apt update
sudo apt install openjdk-8-jdk
If several versions of Java are installed in your system, you can switch between the versions using the command
⚠️ IF SEVERAL VERSIONS OF JAVA ARE INSTALLED, IT IS VERY IMPORTANT TO SET THE JAVA SDK AND JAVAC TO THE SAME VERSIONS, IF NOT THE CODE WILL GENERATE ERROR
sudo update-alternatives --config java
sudo update-alternatives --config javac
Terminal command for checking Java version
java -version
javac --version
Response:
openjdk version "1.8.0_392"
OpenJDK Runtime Environment (build 1.8.0_392-8u392-ga-1~22.04-b08)
OpenJDK 64-Bit Server VM (build 25.392-b08, mixed mode)
javac 1.8.0_392
- Downlaod Fiji from here
- Extract the files to the desired folder
- Navigate to fiji-linux64/Fiji.app folder, right-click on ImageJ-linux64, on the permissions tab, make sure Allow executing file as a program option checkbox is selected.
- Download ImageJAugmentation using the command
git clone https://github.com/jithin8mathew/ImageJAugmentation.git
, assuming you have git installed. - Once ImageJ window appears, select open> ImageAugmentor.java
- CTRL + R will compile and run the script if the right Java version is chosen
- Download Java 8 from Oracle Java SE 8 Archive
- Downlaod appropriate DMG file and dobule click on it to install.
- Downlaod Fiji from here
- Once Fiji is downloaded, CONTROL + CLICK, the select OPEN to install the application.
- Once ImageJ window appears, select open> ImageAugmentor.java
- Flipping:
- Horizontal Flip
- Vertical Flip
- Rotation:
- Random Rotation
- Scaling:
- Random Scaling
- Translation:
- Random Translation
- Soothing:
- Random Smoothing
- Sharpening:
- Random Sharpening
- Color Jittering:
- Random changes to brightness, contrast
- Noise:
- Add random noise to the image
- Blur:
- Gaussian Blur
- Contrast Enhancement:
- Adjusting contrast
- Brightness Adjustment:
- Adjusting brightness
For object detection benchmark, we used Global Wheat Head Detection Dataset, which can be accessed for your own testing. The dataset needs to pre-processed with the following code to work with YOLOv8 hosted by Ultralytics YOLOv8.
Dataset were split into YOLO format using the following script with 90:10 ratio.
YOLOv8l from Ultralytics was used for the object detect training experimentation.
For each Deep Learning methods that we test in the study (classification, detection, and segmentation), we perform training and validation with 2 variants of the same dataset each.
- AUGMENTED DATASET
- ORIGINAL DATASET
YOLOv8 PEFORMS AUGMENTATION BY DEFAULT AS SEEN HERE. AUGMENTATION PARAMETERS IN THE DEFAULT CONFIGURATION NEEDS TO BE SET TO ZERO TO OVERRIDE THE DEFAULT HYPERPARAMETERS.
ORIGINAL DATASET
- Training: 5877 images
- Validation: 631 images AUGMENTED DATASET
- Training: 4702(original) + 1175(augmented)
- Validation: 631 images
from ultralytics import YOLO
model = YOLO('yolov8l.pt')
results = model.train(data='/home/pauloflores/Documents/imageJ_project/dataset/YOLOv8_data_format/data.yaml',
epochs=100,
imgsz=1024,
save=True,
batch = 8,
# device=[0,1],
project="ImgeJ_Augmentor",
name="Non_augmented_OD",
# DISABLING DATA AUGMENTATION PARAMETERS
hsv_h = 0.0,
hsv_s = 0.0,
hsv_v = 0.0,
degrees = 0.0,
translate = 0.0,
scale = 0.0,
shear = 0.0,
perspective = 0.0,
flipud = 0.0,
fliplr = 0.0,
mosaic = 0.0,
mixup = 0.0,
copy_paste = 0.0,
)
Fusarium Blight Head dataset was used to peform image classification. Augmentation was performed with the following ratio [0.5,0.4,0.3,0.2,0.1] against original dataset, resulting in {0.5: 564, 0.4: 451, 0.3: 338, 0.2: 225, 0.1: 112} images accross the entire dataset.
ORIGINAL DATASET
- Total Images: 1126
- Training: 900
- Validation: 225
AUGMENTED DATASET
- Total Images: 1872
- Training: 1498
- Validation: 374
- Currently if there is a folder inside the read_directory, it reads the folder and resutls in failure to generate image
- Sometimes images are overwirtten, resulting in lesser no of augemted images than the user anticipates.