Advertisement
Guest User

exam

a guest
Jun 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. ## module 03
  2. ## exercise 05
  3. ## simple look-up tables: brightness and contrast
  4.  
  5. import cv2
  6. import numpy as np
  7. from matplotlib import pyplot as plt
  8.  
  9. ## load image
  10. img = cv2.imread('/home/pi/Workfolder/images/bear.bmp',0)
  11.  
  12. ## changing brightness by simply adding a scalar:
  13.  
  14. dst = cv2.add(img,100)
  15.  
  16. ## changing contrast by muliplying with a scalar:
  17. dst2 = cv2.multiply(img,2)
  18.  
  19. ## display images
  20. plt.subplot(121),plt.imshow(img, cmap = "gray"),plt.title('Original')
  21. plt.xticks([]), plt.yticks([])
  22. plt.subplot(122),plt.imshow(dst, cmap = "gray"),plt.title('Brightness')
  23. plt.xticks([]), plt.yticks([])
  24. plt.subplot(122),plt.imshow(dst1, cmap = "gray"),plt.title('Contrast')
  25. plt.xticks([]), plt.yticks([])
  26. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement