Advertisement
Guest User

image lab1 assignment2

a guest
Feb 24th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Feb 24 22:57:55 2020
  4.  
  5. @author: Sajid
  6. """
  7. import numpy as np
  8. import cv2
  9. import math
  10. img = cv2.imread('C:/Users/Sajid/Desktop/Lenna_(test_image).jpg',cv2.IMREAD_GRAYSCALE)
  11. cv2.imshow('input image',img)
  12. print(img.max())
  13. print(img.shape)
  14. out=[]
  15. for i in range (8):
  16. out.append(img.copy())
  17.  
  18. for k in range(8):
  19. for i in range(img.shape[0]):
  20. for j in range(img.shape[1]):
  21. a = img.item(i,j)
  22. if (a & (1 << k)):
  23. #print('slk')
  24. out[k].itemset((i,j),255)
  25. else:
  26. out[k].itemset((i,j),0)
  27. #print('nonono')
  28.  
  29.  
  30. for i in range(8):
  31. cv2.imshow('output image %d' %(i),out[i])
  32.  
  33.  
  34. cv2.waitKey(0)
  35. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement