title: get the lowest and highest most popular hue color from an image
body: <p>I have an image and I want to find the most dominant lowest hue colour and the most dominant highest hue colour from an image.</p>
  
  <p>It is possible that there are several colours/hues that are close to each other in populace to be dominant and if that is the case I would need to take an average of the most popular.</p>
  
  <p>I am using emgu framework here.</p>
  
  <p>I load an image into the HSV colour space.</p>
  
  <p>I split the hue channel away from the main image.</p>
  
  <p>I then use the DenseHistogram to return my ranges of 'buckets'.</p>
  
  <p>Now, I could enumerate through the bin collection to get what I want but I am mindful of conserving memory when and wherever I can.</p>
  
  <p>So, is there a way of getting what I need at all from the DenseHistogram 'object'?</p>
  
  <p>i have tried MinMax (as shown below) and I have consider using linq but not sure if that is expensive to use and/or how to use it with just using a float array.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>            float[] GrayHist;
  
              Image&lt;Hsv, Byte&gt; hsvSample = new Image&lt;Hsv, byte&gt;("An image file somewhere");
              DenseHistogram Histo = new DenseHistogram(255, new RangeF(0, 255));
              Histo.Calculate(new Image&lt;Gray, Byte&gt;[] { hsvSample[0] }, true, null);
              GrayHist = new float[256];
              Histo.MatND.ManagedArray.CopyTo(GrayHist, 0);
              float mins;
              float maxs;
              int[] minVals;
              int[] maxVals;
  
              Histo.MinMax(out mins, out maxs, out minVals, out maxVals); //only gets lowest and highest and not most popular
              List&lt;float&gt; ranges= GrayHist.ToList().OrderBy( //not sure what to put here..
  </code></pre>