Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. image = cv2.imread('images/input.jpg')
  5.  
  6. # Create a matrix of ones, then multiply it by a scaler of 100
  7. # This gives a matrix with same dimesions of our image with all values being 100
  8. M = np.ones(image.shape, dtype = "uint8") * 175
  9.  
  10. # We use this to add this matrix M, to our image
  11. # Notice the increase in brightness
  12. added = cv2.add(image, M)
  13. cv2.imshow("Added", added)
  14.  
  15. # Likewise we can also subtract
  16. # Notice the decrease in brightness
  17. subtracted = cv2.subtract(image, M)
  18. cv2.imshow("Subtracted", subtracted)
  19.  
  20. cv2.waitKey(0)
  21. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement