import numpy as np import cv2 class Operation: def __init__(self): pass def merge(self, image_left, image_right, column): """ Merge image_left and image_right at column (column) image_left: the input image 1 image_right: the input image 2 column: column at which the images should be merged returns the merged image at column """ # add your code here merged_image = np.zeros(image_left.shape, np.uint8) merged_image[:, :column] = image_left[:, :column] merged_image[:, column:] = image_right[:, column:] # Please do not change the structure return merged_image # Currently the original image is returned, please replace this with the merged image def intensity_scaling(self, input_image, column, alpha, beta): """ Scale your image intensity. input_image: the input image column: image column at which left section ends alpha: left half scaling constant beta: right half scaling constant return: output_image """ # add your code here output_image = np.zeros(input_image.shape, np.uint8) output_image[:, :column] = input_image[:, :column] * alpha output_image[:, column:] = input_image[:, column:] * beta # Please do not change the structure return output_image # Currently the input image is returned, please replace this with the intensity scaled image def centralize_pixel(self, input_image, column): """ Centralize your pixels (do not use np.mean) input_image: the input image column: image column at which left section ends return: output_image """ # add your code here output_image = input_image.copy() output_image = output_image.astype(float) ml = np.sum(input_image[:, :column])/(input_image[:, :column].shape[0] * input_image[:, :column].shape[1]) mr = np.sum(input_image[:, column:])/(input_image[:, column:].shape[0] * input_image[:, column:].shape[1]) o_l, o_r = 128-ml, 128-mr output_image[:, :column] = input_image[:, :column] + o_l output_image[:, column:] = input_image[:, column:] + o_r output_image = output_image.clip(0, 255) return output_image # Currently the input image is returned, please replace this with the centralized image