Hello this is in python! Please write this code of merging two images together. Please read the rules. The inputs to your function are: (i) image left: grace\_1.png (size: 350 Rows X 340 Cols), (ii) image right: grace\_2.png (size: 350 Rows X 340 Cols), (iii) image column (c) at which the images should be merged. image_op/operations.py: Edit the function merge Define a new image as follows: the first c columns (default value = 155) should be equal to the first c columns of the left image (grace_1.png). The remaining columns should be equal to the columns greater than c from the right image (grace_2.png). 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
Hello this is in python! Please write this code of merging two images together. Please read the rules.
The inputs to your function are: (i) image left: grace\_1.png (size: 350 Rows X 340 Cols), (ii) image right: grace\_2.png (size: 350 Rows X 340 Cols), (iii) image column (c) at which the images should be merged.
- image_op/operations.py: Edit the function merge
- Define a new image as follows: the first c columns (default value = 155) should be equal to the first c columns of the left image (grace_1.png). The remaining columns should be equal to the columns greater than c from the right image (grace_2.png).
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
# Please do not change the structure
return image_left # Currently the original image is returned, please replace this with the merged image
Step 1: Create instances of type Image for both left image and right image.
Step 2: Prompt and accept column at which the images must be merged from user and invoke the merge() function by passing the left image, right image and column.
Step 3: Define the merge() function. Determine the size of left and right images.
Step 4: Create new image whose dimension matches with the left image. Paste the left image.
Step 5: Crop the right image from column c+1 onward till the end.
Step 6: Paste the extracted portion of right image in the new image at column c+1. Thus, new_image contains the first c columns of left image and from columns c+1 till remaining columns of right image.
Step 7: Return the newly constructed image. Display the image
Step by step
Solved in 4 steps with 2 images