title: Histogram Equalization based on HSI model
body: <p>I am using Python 2.7 on Debian Linux along with matplotlib, Numpy and Scipy and PIL. 
  I am able to generate a histogram for the H S and I parameters of an image using the code mentioned. I intend to apply histogram equalization on the H S and I histograms and then convert it back to a resultant image so that I can compare the changes. Can somebody help me with the necessary code for histogram equalization and converting back the equalized histogram to an image. </p>
  
  <pre><code>import scipy
  from scipy import ndimage
  import matplotlib.pyplot as plt
  import matplotlib.colors as colors
  import numpy as np
  from scipy import misc
  import scipy.misc
  
  img = scipy.misc.imread("/home/subhradeep/Desktop/testc.jpg")
  array=np.asarray(img)
  arr=(array.astype(float))/255.0
  img_hsv = colors.rgb_to_hsv(arr[...,:3])
  
  lu1=img_hsv[...,0].flatten()
  plt.subplot(1,3,1)
  plt.hist(lu1*360,bins=360,range=(0.0,360.0),histtype='stepfilled', color='r', label='Hue')
  plt.title("Hue")
  plt.xlabel("Value")
  plt.ylabel("Frequency")
  plt.legend()
  
  lu2=img_hsv[...,1].flatten()
  plt.subplot(1,3,2)                  
  plt.hist(lu2,bins=100,range=(0.0,1.0),histtype='stepfilled', color='g', label='Saturation')
  plt.title("Saturation")   
  plt.xlabel("Value")    
  plt.ylabel("Frequency")
  plt.legend()
  
  lu3=img_hsv[...,2].flatten()
  plt.subplot(1,3,3)                  
  plt.hist(lu3*255,bins=256,range=(0.0,255.0),histtype='stepfilled', color='b', label='Intesity')
  plt.title("Intensity")   
  plt.xlabel("Value")    
  plt.ylabel("Frequency")
  plt.legend()
  plt.show()
  </code></pre>
  
  <p>I need to implement the eq (4) in python </p>
  
  <p><img src="https://i.stack.imgur.com/817XM.png" alt="Algorithm Description"></p>