Plueseval - Numpy - Image
Plueseval - Numpy - Image
Dataset Information:
Using numpy perform image processing and
image augmentation operations on animal.png.
The data sample for the required analysis is
available in the folder data.
. flip_left_to_right(self, img_data):
o Flip an image from left -> right, (flipping over
y_axis).
. flip_top_to_bottom(self, img_data):
o Flip an image from top -> bottom, (flipping
over x_axis)
· rotate_180(self, img_data):
o Rotate an image by 180 degrees in a
clockwise direction.
· mask_image(self, img_data,
mask_img_data):
o Composite the image according to the given
mask image. In the mask image, there will
white portion, have to composite the original
image in that white portion.
· clrreduction_image(self, img_data):
o Reduce the color intensity by 64 for a given
image.
______________________________________________________________________________
import numpy as np
import re
class Solution:
def add_padding(self, img_data, pad_size):
"""
Add black padding around an image based on given pad_size parameter.
:param img_data: numpy array of an image
:param pad_size: padding size
:return: numpy array with black padding around an image
"""
padded_img_data = np.pad(img_data, ((pad_size, pad_size), (pad_size,
pad_size), (0, 0)), mode='constant')
return padded_img_data