SHARE
TWEET

Untitled

a guest Jun 15th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import scipy.misc, math
  3. from PIL import Image
  4.  
  5. img=Image.open('pictures28/lena512.bmp')
  6.  
  7. img1=scipy.misc.fromimage(img)
  8.  
  9. f1=img1.flatten()
  10.  
  11. hist,bins=np.histogram(img1,256,[0,255])
  12.  
  13. cdf=hist.cumsum()
  14.  
  15. cdf_m=np.ma.masked_equal(cdf,0)
  16. num_cdf_m=(cdf_m-cdf_m.min())*255
  17. den_cdf_m=(cdf_m.max()-cdf_m.min())
  18.  
  19. cdf_m=num_cdf_m/den_cdf_m
  20.  
  21. cdf=np.ma.filled(cdf_m,0).astype('uint8')
  22.  
  23. im2=cdf[f1]
  24.  
  25. im3=np.reshape(im2,im1.shape)
  26.  
  27. im4=scipy.misc.toimage(im3)
  28.  
  29. im4.show()
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
 
Top