SHARE
TWEET

Untitled

a guest May 27th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import cv2
  2. import numpy as np
  3.  
  4. img1 = cv2.imread("we1.png", 0)
  5. img2 = cv2.imread("we2.png", 0)
  6.  
  7. lenna = cv2.imread("lenna.png", 1)
  8. lenna2 = cv2.imread("lena_tmpl.png", 1)
  9.  
  10. hsep = np.full((img1.shape[0], 5), 127, np.uint8)
  11. hsep2 = np.full((lenna.shape[0], 5), 127, np.uint8)
  12.  
  13. add1 = img1 + img2
  14. sub1 = img1 - img2
  15. mul1 = img1 * img2
  16. and1 = img1 & img2
  17. or1 = img1 | img2
  18. not1 = 255 - img1
  19.  
  20. add2 = img1 + img1
  21. sub2 = img1 - img1
  22. mul2 = img1 * img1
  23. and2 = img1 & img1
  24. or2 = img1 | img1
  25. not2 = 255 - img1
  26.  
  27. add3 = lenna + lenna
  28. sub3 = lenna - lenna
  29. mul3 = lenna * lenna
  30. and3 = lenna & lenna
  31. or3 = lenna | lenna
  32. not3 = 255 - lenna
  33.  
  34. add4 = lenna + lenna2
  35. sub4 = lenna - lenna2
  36. mul4 = lenna * lenna2
  37. and4 = lenna & lenna2
  38. or4 = lenna | lenna2
  39. not4 = 255 - lenna
  40.  
  41. cv2.namedWindow('zad11', cv2.WINDOW_NORMAL)
  42. cv2.imshow('zad11', np.vstack((
  43.     np.hstack((img1, hsep, img2)),
  44.     np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
  45.     np.hstack((add1, hsep, sub1)),
  46.     np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
  47.     np.hstack((mul1, hsep, and1)),
  48.     np.full((5,np.hstack((img1, hsep, img2)).shape[1]), 127, np.uint8),
  49.     np.hstack((or1, hsep, not1))
  50. )))
  51.  
  52. cv2.namedWindow('zad12', cv2.WINDOW_NORMAL)
  53. cv2.imshow('zad12', np.vstack((
  54.     np.hstack((img1, hsep, img1)),
  55.     np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
  56.     np.hstack((add2, hsep, sub2)),
  57.     np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
  58.     np.hstack((mul2, hsep, and2)),
  59.     np.full((5,np.hstack((img1, hsep, img1)).shape[1]), 127, np.uint8),
  60.     np.hstack((or2, hsep, not2))
  61. )))
  62.  
  63. cv2.waitKey(0)
  64.  
  65. cv2.namedWindow('zad13', cv2.WINDOW_NORMAL)
  66. cv2.imshow('zad13', np.vstack((
  67.     np.hstack((lenna, lenna)),
  68.     np.hstack((add3, sub3)),
  69.     np.hstack((mul3, and3)),
  70.     np.hstack((or3, not3))
  71. )))
  72.  
  73. cv2.namedWindow('zad14', cv2.WINDOW_NORMAL)
  74. cv2.imshow('zad14', np.vstack((
  75.     np.hstack((lenna, lenna2)),
  76.     np.hstack((add4, sub4)),
  77.     np.hstack((mul4, and4)),
  78.     np.hstack((or4, not4))
  79. )))
  80.  
  81. cv2.waitKey(0)
  82. cv2.destroyAllWindows()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top