Creating Own Image By OpenCV(35)

Lakshmi Priya Patro
3 min readJan 24, 2022

Task Description

πŸ”… Task 35.1
πŸ“Œ Create the image by yourself Using Python Code
πŸ”… Task 35.2
πŸ“Œ Take 2 images, crop some parts of both the images and swap them.
πŸ”… Task 35.3
πŸ“Œ Take 2 images and combine them to form a single image. For example, collage

Steps to create your own image using OpenCV

Step-1: Firstly import cv2 for image processing and NumPy module for defining the dimensions

Step-2: Now we will create and print a smiley image using numpy.array

Step -3: Now by using cv2 we can create a circle of the following dimensions shown in the above image to form a smiley.

Steps to Crop and swap two different images

Step-1: Import cv2 and numpy module

Step-2 (a): Load the pic1 and also provide its dimensions.

Step -2 (b): Load pic2 and also provide its dimensions.

Step-3: Here we have to crop a part of the images (pic1, pic2), and then we have to swap them upon each other, keeping in mind the dimensions of the images should be the same.

cropping and swapping the pic2 into pic1
cropping and swapping the pic1 into pic2

Steps for Combining two images to form a single image(collage)

Step-1: Import the cv2 library and numpy module

Step-2: Load the first image and note down its dimensions.

Step-3: Load the second image and resize it based on the dimensions of the first image.

Step-4: Resizing the images with respect to the required dimensions

Step-5: Now stack both the images upon each other to make a collage.

Task Completedβ˜‘οΈ

Thanks for Reading!!

--

--