

# because as we alreay load image into the memory, so we are using flow() function, to apply transformation ImageDataGen = ImageDataGenerator(zoom_range=) # now here below we creating the object of the data augmentation class # we converting the image which is in PIL format into the numpy array, so that we can apply deep learning methods # python program to demonstrate the zooming of the image with the zoom_range argumentįrom import load_imgįrom import img_to_arrayįrom import ImageDataGenerator If your image is at another location then specify the full path to the load_img(/path/of/the/image) function. Because then only it will read the image. To run this program we have to keep the image (any image) in the same folder where you will keep this python file. We will save the below python program with the name randomZoom.py. But be cautious that will have no effect as this is the boundary. Value of the zoom less than 1.0 magnifies the image and more than 1.0 will zoom out the image.įor example:, in this range the zoom will enlarge the image which means the object of the image will become 60% larger or come closer and if the value is greater than 1.0 e.g. Zoom also has some boundary values as we have in the brightness parameter case. For example, if we specify the float value as 0.5, then it actually becomes like as we subtract 0.5 from 1 in the first range and add 0.5 to 1 in the second range which actually means zoom-in 50% and zoom-out 150%. If we specify the value of the zoom-in using float value then it will be. We can specify the percentage value of the zooms either in a float, range in the form of an array, or python tuple. This method uses the zoom_range argument of the ImageDataGenerator class. This method randomly zooms the image either by zooming in or it adds some pixels around the image to enlarge the image.

The zoom augmentation method is used to zooming the image. So if you haven't checked these, please do check them out.Ĭode: The code for this article, can be downloaded from the following GitHub link: Random Zoom Augmentation In the previous articles of the Image Augmentation series, we have already covered the following: We will be using Keras ImageDataGenerator class, along with providing the zoom_range argument. Random Zoom Image augmentation is used to generate images with varying zoom levels for feeding our deep learning model.
