TASK -4
1 min readSep 6, 2021
eam Task 4 Description π
π
Task 4.1
π Create image by yourself Using Python Code.
π
Task 4.2
π Take 2 image crop some part of both image and swap it.
π
Task 4.3
π Take 2 image and combine it to form single image. For example collage
import cv2
import numpyTASK 4.1: Creating image using python code
image=numpy.zeros((400,600,3))
imagemade=cv2.circle(image,(300,200),100,[245,60,42],4)
imagemade=cv2.circle(image,(300,200),120,[245,60,42],4)
imagemade=cv2.rectangle(image,(450,100),(550,200),[245,60,42],4)
imagemade=cv2.rectangle(image,(50,50),(550,350),[245,60,42],4)
imagemade=cv2.rectangle(image,(450,20),(500,50),[245,60,42],4)
cv2.imshow("circle", image)
cv2.waitKey()
cv2.destroyAllWindows()TASK 4.2: Take 2 images crop some part of both the images and swap it.
#taking 2 images
thor=cv2.imread("thor.jpg")
iron=cv2.imread("iron man.jpg")#thor crop
cthor=thor[100:260,150:300]
cv2.imshow("thor.jpg", cthor)
cv2.waitKey()
cv2.destroyAllWindows()#iron crop
ciron=iron[100:260,150:300]
cv2.imshow("iron.jpg", ciron)
cv2.waitKey()
cv2.destroyAllWindows()#swaping the cropped images
crop1=numpy.copy(cthor)
crop2=numpy.copy(ciron)
thor[100:260,150:300,] = crop2
iron[100:260,150:300,] = crop1#showing images 1 after cropping
cv2.imshow("image1",thor)
cv2.waitKey()
cv2.destroyAllWindows()#showing images 2 after cropping
cv2.imshow("image1",iron)
cv2.waitKey()
cv2.destroyAllWindows()
TASK 4.3: Making a collage from two images
#combining two images
collage=numpy.hstack((thor,iron))#Destroy all windows
#showing collage
cv2.imshow("collage",collage)
cv2.waitKey()
cv2.destroyAllWindows()