private void button1_Click(object sender, EventArgs e) { Histogram histogram = img.BuildHistogram(); //low bins to 0 out int low_bins = histogram.GetNumBinsWithItems(Convert.ToInt32(img.GetHeight() * img.GetWidth() * .10)); AdvColor low_color = histogram.GetBinColor(low_bins); int high_bins = histogram.GetNumBinsWithItems(Convert.ToInt32(img.GetHeight() * img.GetWidth() * .90)); AdvColor high_color = histogram.GetBinColor(high_bins); AdvColor[,] pixels = img.HistogramStretch(low_color, high_color, histogram, ColorPlane.eGreen); SortedDictionary <AdvColor, int> bins = histogram.GetHistogram(); foreach (KeyValuePair <AdvColor, int> bin in bins) { chart1.Series["Series1"].Points.AddXY(bin.Key.GetColor(ColorPlane.eGreen), bin.Value); } RGBImage img2 = new RGBImage(pixels); img.SaveToImage(pixels, "histo_stretch.png"); Histogram histogram2 = img2.BuildHistogram(); SortedDictionary <AdvColor, int> bins2 = histogram2.GetHistogram(); foreach (KeyValuePair <AdvColor, int> bin in bins2) { chart2.Series["Series1"].Points.AddXY(bin.Key.GetColor(ColorPlane.eGreen), bin.Value); } }