Image Processing Using Python3

def create():
photo= np.zeros((500,500,3))
nphoto = cv2.circle(photo,(100,100),50,(255,0,0),5)
nphoto = cv2.circle(photo,(150,150),50,(0,255,0),5)
nphoto = cv2.circle(photo,(200,200),50,(0,0,255),5)
nphoto = cv2.circle(photo,(250,250),50,(0,255,205),5)
nphoto = cv2.circle(photo,(300,300),50,(145,255,0),5)
show(photo)
create()
import cv2
photo= cv2.imread('<<image_name>>')
def crop(img1, img2):
photo1= cv2.imread(img1)
photo2= cv2.imread(img2)
c1= photo1[150:500, 50:500]
c2= photo2[150:500, 50:500]
show(c1)
show(c2)
def show(img):
cv2.imshow('photo', img)
cv2.waitKey()
cv2.destroyAllWindows()
Cropped Images
def swap(img1, img2):
photo1= cv2.imread(img1)
photo2= cv2.imread(img2)
photo3= cv2.imread(img1)
c1= photo3[150:500, 50:500]
c2= photo2[150:500, 50:500]
photo1[150:500, 50:500]= c2
photo2[150:500, 50:500]= c1
show(photo1)
show(photo2)
Image Swapping
def collage(img1, img2):
photo1= cv2.imread(img1)
photo2= cv2.imread(img2)
c1= photo1[150:500, 50:500]
c2= photo2[150:500, 50:500]
horizontal= numpy.hstack((c1, c2))
vertical= numpy.vstack((c1, c2))
show(horizontal)
show(vertical)
NumPy.hstack
numpy.vstack
  • Automated inspection and surveillance.
  • Robot and driver-less car navigation and control.
  • Medical image analysis.
  • Video/image search and retrieval.
  • Movies — 3D structure from motion.
  • Interactive art installations.
  • Street view image stitching.

--

--

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