In [1]:
### Run below if necessary
##import sys
##sys.path.append('/usr/local/lib/python2.7/site-packages')
import math
import csv,gc
import matplotlib
import numpy as np
import cv2
#%matplotlib
BINS = 32
In [2]:
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
from skimage import data, img_as_float
from skimage import exposure
In [4]:
a = np.random.randint(0,10,(6,7,8))
print a
In [12]:
img = np.asarray(a)
print img
print " "
print img[0]
print img[1]
print " "
imgflat = img.reshape(-1)
print imgflat
print imgflat.sum()
print " "
fig = plt.hist(imgflat, bins=255)
plt.title('Histogram')
plt.show()
print " "
#clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
img_grey = np.array(imgflat * 255, dtype = np.uint8)
#threshed = cv2.adaptiveThreshold(img_grey, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 3, 0)
cl1 = clahe.apply(img_grey)
#cv2.imwrite('clahe_2.jpg',cl1)
#cv2.startWindowThread()
#cv2.namedWindow("adaptive")
#cv2.imshow("adaptive", cl1)
#cv2.imshow("adaptive", threshed)
#plt.imshow(threshed)
print " "
localimgflat = cl1 #cl1.reshape(-1)
print localimgflat
print localimgflat.sum()
print " "
fig = plt.hist(localimgflat, bins=255)
plt.title('Locally Equalized Histogram')
plt.show()
In [13]:
print " "
fig = plt.hist(imgflat, bins=255)
plt.title('Histogram')
plt.show()
print " "
fig = plt.hist(localimgflat, bins=255)
plt.title('Locally Equalized Histogram')
plt.show()
In [ ]:
!ls
In [ ]:
#!sudo yum install numpy opencv*
sudo ls
unko1234