Skip to main content

Take 2 images, crop some part of both the images and swap them

 



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])


Cropping the image


cropimg1 = img1[1000:1700 , 400:1300]
plt.imshow(cropimg1)


Resizing the image


cropimg1= cv2.resize(cropimg1,(900,400))
cropimg2= cv2.resize(cropimg2,(900,700))


Swapping the Two part


img1[1000:1700 , 400:1300] = cropimg2
plt.imshow(img1)


Concatenating the hstack

newimg = np.hstack((img1,img2))

Comments

Popular posts from this blog

Run any GUI software in docker container

 

Vivo Announces Android 11-Based Funtouch OS 11 Beta Update Schedule for India

Vivo has announced the rollout schedule for the beta version of its Android 11-based Funtouch OS 11 in India that will go on till June. The Vivo V20 debuted with the stable version of Android 11 with Funtouch OS 11 in October, and the Vivo X50 Pro started receiving the update last month, but the company was yet to announce the schedule for its older models. The update schedule has devices ranging from the budget segment to the premium segment. The company took to Twitter to reveal its Android 11-based Funtouch OS 11 beta rollout plan. Vivo clarified that users will receive the update on a batch-by-batch basis. The Vivo V20 and the Vivo V20 Pro are already running on the latest OS. The Vivo X50 Pro, too, started receiving the update last month, Vivo said. The Vivo V19 and the Vivo X50₹ 34,990 will start receiving the Android 11-based Funtouch OS 11 beta version update at the end of January 2021, while Vivo V17, Vivo V17 Pro₹ 27,375, Vivo V15 Pro, and Vivo S1 will start receiving the upd...

Introduction Types of Computer Network

  What is a Computer Network? Computer networks is bunch of computers connected through optical cables, wires and fibers so that it interacts with each other through networks. The goal is to share the content and the information among the system of same network or other. In computer networks there are different types of networks that shares the information among each other they maybe simplex or complex ones.