Guest User

Untitled

a guest
Jul 15th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Sat Jul 14 23:59:48 2018
  5.  
  6. @author: Callmetorre
  7. """
  8.  
  9. import cv2
  10. import numpy as np
  11. import matplotlib.pyplot as plt
  12.  
  13. def getGreenImage(img):
  14. R = img[:, :, 0]
  15. G = img[:, :, 1]
  16. B = img[:, :, 2]
  17. return R * 0 + G * 1 + B * 0
  18.  
  19. def printImage(img):
  20. f = plt.figure()
  21. f.add_subplot(1,2, 1)
  22. plt.imshow(img, cmap='gray')
  23.  
  24. def getIntensities(img):
  25. intensities = []
  26. for x in range(0, img.shape[0]):
  27. for y in range(0, img.shape[1]):
  28. if img[x,y] > 100:
  29. temp = (x, y)
  30. intensities.append(temp)
  31. return intensities
  32.  
  33. #def equalization(hist):
  34. # cdf = hist.cumsum()
  35. # cdf_m = np.ma.masked_equal(cdf,0)
  36. # cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
  37. # cdf = np.ma.filled(cdf_m,0).astype('uint8')
  38. # return cdf
  39.  
  40. img = cv2.imread('/Users/Callmetorre/Desktop/image015.png')
  41. img_gray_green = getGreenImage(img)
  42. #hist = cv2.calcHist([img], [0], None, [256], [0, 256]).flatten()
  43. #algo = equalization(hist)
  44. filtered_img = cv2.medianBlur(img_gray_green, 49)
  45. intensities = getIntensities(img_gray_green)
  46. printImage(img_gray_green)
  47. printImage(filtered_img)
  48. #printImage(algo[img_gray_green])
Add Comment
Please, Sign In to add comment