Libraries Required for this
1.numpy
2.Matplotlib
3.opencv
Taking input from the user using
img1 = cv2.imread("imageone.jpg")
img2 = cv2.imread("imagetwo.png")
Converting both the images into RGB format from BGR
img1 = cv2.cvtColor(img1,cv2.COLOR_BGR2RGB)
Showing image using Matplotlib
plt.imshow(imagename)
Make sure that both the images are of same sizes to add them together one can check the shape of the image and confirm whether both image has same size
using
imgname.shape
return (x,y,[RGB])
concatenating two images using the below code
im_h = cv2.hconcat([imageone, imagetwo])
a = cv2.cvtColor(im_h,cv2.COLOR_BGR2RGB)
Showing image using Matplotlib
plt.imshow(imagename)
Writing the image using imwrite()
cv2.imwrite("imagename.png",a)
Comments