private void AddHistogram(Image <Bgr, byte> image, Color color, HistogramBox histogramBox) { using (DenseHistogram histogram = new DenseHistogram(256, new RangeF(0f, 255f))) { Mat mat = new Mat(); if (color == Color.Black) { histogram.Calculate(new Image <Gray, byte>[] { image.Convert <Gray, byte>() }, false, null); } else if (color == Color.Blue) { histogram.Calculate(new Image <Gray, byte>[] { image[0] }, false, null); } else if (color == Color.Red) { histogram.Calculate(new Image <Gray, byte>[] { image[1] }, false, null); } else if (color == Color.Green) { histogram.Calculate(new Image <Gray, byte>[] { image[2] }, false, null); } else { return; } histogram.CopyTo(mat); histogramBox.ClearHistogram(); histogramBox.AddHistogram(color.ToString(), color, mat, 256, new float[] { 0f, 255f }); histogramBox.Refresh(); } }
void AddHist2Box(HistogramBox box, ref DenseHistogram[] histogramArr, dynamic createhist, float dw, float up) { histogramArr = createhist(dw, up); for (int i = 0; i < histogramArr.GetLength(0); i++) { if (histogramArr[i] != null) { box.AddHistogram(null, System.Drawing.Color.Black, histogramArr[i], Core.BinSize, new float[] { dw, up }); } } }
void AddHist2Box(HistogramBox box, DenseHistogram[] histogramArr, dynamic createhist) { histogramArr = createhist(); float histmax = (float)(Core.PData.ChipHSize * Core.PData.ChipWSize * 255); var temp = HistogramList; for (int i = 0; i < histogramArr.GetLength(0); i++) { if (histogramArr[i] != null) { box.AddHistogram(i == 0?"Intensity":"Size", System.Drawing.Color.Black, histogramArr[i], Core.BinSize, new float[] { 0, histmax }); } } }
private void BtnFotoSec_Click_1(object sender, EventArgs e) { string FotoGetir = DosyaAdiGetir(); Image <Bgr, byte> renkliFoto = new Image <Bgr, byte>(FotoGetir); FotoImageBox.Image = renkliFoto; //gri image Image <Gray, byte> griFoto = GriGetir(renkliFoto); GriImageBox.Image = griFoto; //binary image Image <Gray, byte> binaryFoto = BinaryGetir(griFoto); BinaryImageBox.Image = binaryFoto; //histogram Mat m = HistogramGetir(griFoto); HistogramBox.ClearHistogram(); HistogramBox.AddHistogram("Gri Histogram", Color.Gray, m, 256, new float[] { 0.0f, 256.0f }); HistogramBox.Refresh(); }