Creating Images using numpy

Task 1 : Create Image using numpy

Task 2 : Crop two images and swap their cropped parts

I have taken two images of cats. I would try to swap faces of both the cats. 

Step 1 : Importing cv2 and numpy libraries

Step 2: Loading image 1

Also determine the shape of this image.

Step3 : Load 2nd image

The face size of both the cats is different , so the swap of faces may not be very accurate. 

Step4: Examine the locations of face of x ( first image ) and then store them in a separate variable. And similarly crop y also

Step 5: Check the cropped images

Step 6: Now Fianlly replace those coordinates of the image with these variables

Make sure , the coordinates you have removed , there only the new part should be kept. 

Now lets display the pictures.

Task 3 : Concatenate two images

Let’s concatenate the same images

We can use hstack command to attach them.

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *