Summer- Task 4

Riya Jain
3 min readJun 9, 2021

Task Description

✔Task 4.1

✨Create image by yourself using Python code

First of all, we will import numpy and cv2. I have made an image of size 400*400 filled with black colour. To do this, i have used numpy.zeroes function.

Then Idraw a circle with the help of circle function of cv2 module.

cv2.circle (imageObjectName, (‘center_coordinates’), (‘circle_radius’), (‘color_in_bgr’), ‘stroke_thickness’)

Then I saved the image using cv2 module and displayed the resultant image.

The output will be like this:

✔Task 4.2

✨Take 2 image, crop some part of both image and swap it.

With the help of cv2 module, took two images named ‘two.jpg’ and ‘twoo.jpg’ and shown the size of both the images.

Display both the images:

using the concept of array slicing, I cropped some part of first picture and applied that part to the second photo.

Then display the picture:

Similarly, I did with the second picture.

The first picture looks like this with swapped part of second picture:

The second picture looks like this with swapped part of first picture:

✔Task 4.3

✨Take 2 image and combine it to form a single image. For example- collage.

Using cv2 module, take two pictures(in my case, I took one flower and another scenery image named one.jpg and two.jpg.

Display both the pictures:

crop both the images using array slicing and display the cropped image using cv2 module:

To make a collage, we used concept of array concatenation. we know that an image is stored as an array. so both the cropped pictures are also in array format.

To display them in collage, use array.hstack(pic_1,pic_2) and store it in a variable (in my case it is ‘collage’). Thus, both the pictures will be in one collage.

display the collage using imshow function of cv2 module:

crooped image(first)
cropped image(second)

The collage will look like this:

collage

Thank You for reading:)

--

--

Riya Jain
0 Followers

Learner at Linux World | Teerthanker Mahaveer University