Arsalan Wasim

3 min read 215 views

Image Data Augmentation

Image Data Augmentation_image

A convolutional neural network (CNN) is trained with images from a certain dataset, and the number of images in a dataset defines the accuracy of the model. The more images we have for a particular dataset, the better its ability to generalize will be.

Sometimes you will find that you do not have enough images to train your model and therefore your model will overfit very easily, resulting in a lot of noise in the output predictions by the model. Thus, to fight overfitting and to increase the size of the dataset, you will have to use image data augmentation.

As the name suggests, the goal of  image data augmentation is to increase the size of the dataset. This is typically done by creating artificial samples in the data through image processing techniques such as zooming, panning, rotating, flipping, shifting images in place, and much more. Image data augmentation also helps the CNN learn the additional features, aiding in boosting test set performance.

In this blog, we will make functions in Python to convert an image format from RGB (red, green, blue) to YUV. We will also zoom the image, pan the image, add random brightness, and flip the image.

 

The conversion from RGB format to YUV looks as:

 

Zooming the image results in the following output:

 

Panning the image would look as:

Lastly, brightening the image looks as:

 



Code