private void Histogram_PositionChanged(object sender, AForge.Controls.HistogramEventArgs e) { if (e.Position >= 0 && e.Position < histogram.Values.Length) { label3.Text = $"Level: {e.Position}"; label4.Text = $"Count: {histogram.Values[e.Position]}"; } else { label3.Text = "Level:"; label4.Text = "Count"; } }
// Selection changed in the hostogram private void histogram_SelectionChanged(object sender, AForge.Controls.HistogramEventArgs e) { int min = e.Min; int max = e.Max; int count = 0; levelLabel.Text = min.ToString( ) + "..." + max.ToString( ); // count pixels for (int i = min; i <= max; i++) { count += activeHistogram.Values[i]; } countLabel.Text = count.ToString( ); percentileLabel.Text = ((float)count * 100 / stat.PixelsCount).ToString("F2"); }
// Mouse cursor's position has changed within histogram control private void histogramControl_PositionChanged(object sender, AForge.Controls.HistogramEventArgs e) { if (histogram != null) { int pos = e.Position; if (pos != -1) { textBox.Text = string.Format("Value: {0} Count: {1} Percent: {2:F2}", pos, histogram.Values[pos], ((float)histogram.Values[pos] * 100 / histogram.TotalCount)); } else { textBox.Text = string.Empty; } } }
// Mouse cursor's position has changed within histogram control private void histogram_PositionChanged(object sender, AForge.Controls.HistogramEventArgs e) { int pos = e.Position; if (pos != -1) { levelLabel.Text = pos.ToString( ); countLabel.Text = activeHistogram.Values[pos].ToString( ); percentileLabel.Text = ((float)activeHistogram.Values[pos] * 100 / stats.PixelsCount).ToString("F2"); } else { levelLabel.Text = ""; countLabel.Text = ""; percentileLabel.Text = ""; } }
// Selection has changed within histogram control private void histogramControl_SelectionChanged(object sender, AForge.Controls.HistogramEventArgs e) { if (histogram != null) { int min = e.Min; int max = e.Max; int count = 0; // count pixels for (int i = min; i <= max; i++) { count += histogram.Values[i]; } textBox.Text = string.Format("Values: {0}...{1} Count: {2} Percent: {3:F2}", min, max, count, ((float)count * 100 / histogram.TotalCount)); } }