Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- img1 = cv2.imread("we1.png", 0)
- img2 = cv2.imread("we2.png", 0)
- lenna = cv2.imread("lenna.png", 1)
- lenna2 = cv2.imread("lena_tmpl.png", 1)
- hsep = np.full((img1.shape[0], 5), 127, np.uint8)
- hsep2 = np.full((lenna.shape[0], 5), 127, np.uint8)
- add1 = img1 + img2
- sub1 = img1 - img2
- mul1 = img1 * img2
- and1 = img1 & img2
- or1 = img1 | img2
- not1 = 255 - img1
- add2 = img1 + img1
- sub2 = img1 - img1
- mul2 = img1 * img1
- and2 = img1 & img1
- or2 = img1 | img1
- not2 = 255 - img1
- add3 = lenna + lenna
- sub3 = lenna - lenna
- mul3 = lenna * lenna
- and3 = lenna & lenna
- or3 = lenna | lenna
- not3 = 255 - lenna
- add4 = lenna + lenna2
- sub4 = lenna - lenna2
- mul4 = lenna * lenna2
- and4 = lenna & lenna2
- or4 = lenna | lenna2
- not4 = 255 - lenna
- cv2.namedWindow('zad11', cv2.WINDOW_NORMAL)
- cv2.imshow('zad11', np.vstack((
- np.hstack((img1, hsep, img2)),
- np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
- np.hstack((add1, hsep, sub1)),
- np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
- np.hstack((mul1, hsep, and1)),
- np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
- np.hstack((or1, hsep, not1))
- )))
- cv2.namedWindow('zad12', cv2.WINDOW_NORMAL)
- cv2.imshow('zad12', np.vstack((
- np.hstack((img1, hsep, img1)),
- np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
- np.hstack((add2, hsep, sub2)),
- np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
- np.hstack((mul2, hsep, and2)),
- np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
- np.hstack((or2, hsep, not2))
- )))
- cv2.waitKey(0)
- cv2.namedWindow('zad13', cv2.WINDOW_NORMAL)
- cv2.imshow('zad13', np.vstack((
- np.hstack((lenna, lenna)),
- np.hstack((add3, sub3)),
- np.hstack((mul3, and3)),
- np.hstack((or3, not3))
- )))
- cv2.namedWindow('zad14', cv2.WINDOW_NORMAL)
- cv2.imshow('zad14', np.vstack((
- np.hstack((lenna, lenna2)),
- np.hstack((add4, sub4)),
- np.hstack((mul4, and4)),
- np.hstack((or4, not4))
- )))
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement