Image<Bgr, Byte> Img = new Image<Bgr, byte>(@"圖片位置"); histogramBox1.GenerateHistograms(Img, 256); histogramBox1.Refresh();可是用這種方式產生出來的直方圖數據沒有辦法被程式拿來利用。
這種時候我們就要用到DenseHistogram這個class了
Image<Bgr, Byte> Img = new Image<Bgr, byte>(@"圖片位置");
DenseHistogram Histo = new DenseHistogram(256, new RangeF(0, 256));
float[] BlueHist;
Histo.Calculate(new Image<Gray, Byte>[] { Img[0] }, false, null);
BlueHist= Histo.GetBinValues();
histogramBox1.AddHistogram("Blue", Color.Blue, Histo, 256, new float[] { 0, 256 });
histogramBox1.Refresh();
用DenseHistogram.Calculate計算直方圖,其中的bool為false時會先清除原本的數據。而要取出計算結果只要使用.GetBinValues就可以得到計算結果的數據了。

沒有留言:
張貼留言