title: How to compute the Cumulative Distribution Function of an image in MATLAB
body: <p>I need to compute the Cumulative Distribution Function of an image. I normalized the values using the following code:</p>
  
  <pre><code>im = imread('cameraman.tif');
  im_hist = imhist(im);
  tf = cumsum(im_hist); %transformation function
  tf_norm = tf / max(tf);
  plot(tf_norm), axis tight
  </code></pre>
  
  <p>Also, when the CDF function is plotted, does the plot have to be somewhat a straight line which ideally should be a straight line to represent equal representation for pixel intensities?</p>