title: adjust the gray level of an image according to its statistical distribution
body: <p>I'm working on a MATLAB image processing project and it wants me to "Convert the color image of the flame in to gray level and adjust the gray level according to its statistical distribution.". Actually, what I don't understand is what it means by saying "adjust the gray level according to its statistical distribution".</p>
  
  <p>In addition it explains a bit about what it means:
  "Let's consider a discrete gray scale image <code>x</code> and let the total number of occurrences of gray level of <code>i</code> be <code>nj</code>, then a pixel of gray level <code>i</code>
  has the probability of occurrence </p>
  
  <pre><code>Px(i)=p(x=i)= nj/n , 0 &lt; i &lt; L
  </code></pre>
  
  <p>where <code>L</code> is the total number of gray levels in the image, <code>n</code> the resultant pixels in the image, and <code>Px(i)</code> the pixels histogram with <code>i</code>, normalized to <code>[0,1]</code>.The cumulative distribution function(CDF) corresponding to <code>Px</code> is defined as</p>
  
  <pre><code>CDFx(i) = (adding from j=0 to i) Px(j)
  </code></pre>
  
  <p>This is the accumulated normalized histogram of the image.
  Next, a transformation of form <code>y = T(x)</code> is created to produce a new image <code>{y}</code>, such that its CDF will be linearized across the value range with number <code>K</code> which is a constant , i.e.</p>
  
  <pre><code>CDFy(i) = iK
  </code></pre>
  
  <p>Can anybody please help me find this transformation called <code>T(x)</code>?</p>