title: Converting CDF of histogram to c# from matlab?
body: <p>How can I convert this matlab code to AForge.net+c# code?</p>
  
  <pre><code>cdf1 = cumsum(hist1) / numel(aa); 
  </code></pre>
  
  <p>I found that there is Histogram.cumulative method is present in Accord.net.
  But I dont know how to use.</p>
  
  <p>Please teaching how to convert. </p>
  
  <pre><code>% Histogram Matching
  %
  
  clear
  clc
  close all
  
  pkg load image
  
  % 이미지 로딩
  aa=imread('2.bmp');
  ref=imread('ref2.png');
  
  figure(1); imshow(aa); colormap(gray)
  figure(2); imshow(ref); colormap(gray)
  
  M = zeros(256,1,'uint8'); % Store mapping - Cast to uint8 to respect data type
  hist1 = imhist(aa); % Compute histograms
  hist2 = imhist(ref);
  
  cdf1 = cumsum(hist1) / numel(aa); % Compute CDFs
  cdf2 = cumsum(hist2) / numel(ref);
  
  % Compute the mapping
  for idx = 1 : 256
  [~,ind] = min(abs(cdf1(idx) - cdf2));
  
  
  M(idx) = ind-1;
  end
  
  % Now apply the mapping to get first image to make
  % the image look like the distribution of the second image
  out = M(double(aa)+1);
  
  figure(3); imshow(out); colormap(gray)
  </code></pre>