Image processing using Numpy Array

import cv2, numpyphoto = numpy.zeros((500,700))photo[100:400 , 100:600] = numpy.ones((300,500))photo[200:300 , 200:500] = numpy.zeros((100,300))photo[200:300 , 300:400] = numpy.ones((100,100))photo[340:360 , 300:400 ] = numpy.zeros((20 , 100))cv2.imshow(‘hi’ , photo)
cv2.waitKey()
cv2.destroyAllWindows()
Final Image
import cv2 , numpyphoto1 = numpy.zeros((500 , 500))
photo2 = numpy.ones((500 , 500))
x = photo2[150:350 , 150:350]
y = photo1[150:350 , 150:350]
x = x.copy()
y = y.copy()
photo2[150:350 , 150:350] = y
photo1[150:350 , 150:350] = x
cv2.imshow(‘1st’ , photo1)
cv2.waitKey()
cv2.destroyAllWindows()
cv2.imshow(‘2nd’ , photo2)
cv2.waitKey()
cv2.destroyAllWindows()
1st and 2nd Images after Swapping .
import cv2 , numpyphoto1 = numpy.zeros((300,300))
photo2 = numpy.zeros((300,300))
photo3 = numpy.zeros((300,300))
photo1[: , 200:300] = numpy.ones((300 , 100))
photo2[100:200 , : ] = numpy.ones((100,300))
photo3[: , :100] = numpy.ones((300 , 100))
cv2.imshow(‘1st’ , photo1)
cv2.waitKey()
cv2.destroyAllWindows()
cv2.imshow(‘2nd’ , photo2)
cv2.waitKey()
cv2.destroyAllWindows()
cv2.imshow(‘3rd’ , photo3)
cv2.waitKey()
cv2.destroyAllWindows()
final_photo = numpy.hstack((photo1 ,photo2,photo3))cv2.imshow(‘final’ , final_photo)
cv2.waitKey()
cv2.destroyAllWindows()
Final Image

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store