Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Image augmentation applies simple transforms to images to create more training examples and help computer vision models generalize better.
A common augmentation pipeline might include horizontal flips, brightness scaling, and random cropping, each applied in a controlled way.
Implement the function
Rules:
[:, ::-1].p and factor b.crop = [top, left, height, width] and returns the sub-image.Output:
| Argument | Type |
|---|---|
| img | np.ndarray |
| crop | list |
| flip | int |
| brightness | float |
| Return Name | Type |
|---|---|
| value | np.ndarray |
Use only NumPy.
Do not use libraries like PIL, OpenCV, etc.
For horizontal flip, you can reverse the columns using NumPy slicing: img[:, ::-1].
Brightness is just element-wise multiplication: img * brightness.
Cropping is 2D slicing: img[top:top+height, left:left+width].