AI Course
Lesson 91: Image Augmentation Techniques
Image augmentation is a technique used to artificially increase the size and diversity of an image dataset by creating modified versions of existing images.
Instead of collecting new data, augmentation generates new training samples by applying transformations such as rotation, flipping, scaling, and color changes.
Real-World Connection
In real-world projects, collecting thousands of labeled images is expensive and time-consuming. Image augmentation helps overcome this limitation by making models learn from variations of the same image.
Applications such as face recognition, medical imaging, self-driving cars, and satellite imagery rely heavily on augmentation to improve accuracy.
Why Image Augmentation Is Important
Deep learning models can easily overfit when trained on small datasets. Augmentation helps models generalize better by exposing them to different variations.
- Reduces overfitting
- Improves model robustness
- Simulates real-world variations
Common Image Augmentation Techniques
- Rotation
- Flipping (horizontal / vertical)
- Scaling and cropping
- Brightness and contrast adjustment
- Noise addition
These transformations do not change the label of the image but make the model more flexible.
Image Augmentation Using OpenCV (Code Example)
Below is a simple example showing how image augmentation can be done using OpenCV.
import cv2
import numpy as np
image = cv2.imread("image.jpg")
# Flip image horizontally
flipped = cv2.flip(image, 1)
# Rotate image
(h, w) = image.shape[:2]
center = (w // 2, h // 2)
matrix = cv2.getRotationMatrix2D(center, 15, 1.0)
rotated = cv2.warpAffine(image, matrix, (w, h))
cv2.imshow("Original", image)
cv2.imshow("Flipped", flipped)
cv2.imshow("Rotated", rotated)
cv2.waitKey(0)
cv2.destroyAllWindows()
What This Code Is Doing
The program first loads an image and creates two augmented versions. One version is flipped horizontally, and the other is rotated slightly.
These transformed images represent new training samples without changing the original image label.
Understanding the Output
You will see three images: the original image, the flipped image, and the rotated image. Although they look different, they represent the same object.
During training, the model treats these as separate samples, improving its learning ability.
Augmentation in Deep Learning Pipelines
In deep learning frameworks, augmentation is often applied dynamically during training rather than saving augmented images to disk.
This allows infinite variations of training data without increasing storage requirements.
When to Use Image Augmentation
- When dataset size is small
- When images vary in orientation or lighting
- When model performance stagnates
Practice Questions
Practice 1: What is the main goal of image augmentation?
Practice 2: Which problem does image augmentation help reduce?
Practice 3: Name one common image augmentation technique.
Quick Quiz
Quiz 1: What technique creates modified versions of existing images?
Quiz 2: Image augmentation usually keeps what unchanged?
Quiz 3: What major benefit does augmentation provide to models?
Coming up next: Generative Vision Models — using AI to create new images.