private void LoadSelectedImage() { // Load an image using ReadFile form2.BeforeImage.ReadFile(imagePath.Text); // Histogram the image HistogramReport report = Algorithms.Histogram(form2.BeforeImage); int[] histogram = new int[256]; report.Histogram.CopyTo(histogram, 0); // Convert the int[] to a double[], which the graph requires. double[] histogramDouble = Array.ConvertAll <int, double>(histogram, delegate(int i) { return(i); }); simpleRangeSelect1.PlotY(histogramDouble); // Process the image ProcessImage(); }
private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e) { simpleGraph1.ClearData(); // Compute the histogram of the regions selected if (imageViewer1.Roi.Count > 0) { using (VisionImage mask = new VisionImage()) { // Find the histogram of a portal of the image in imageViewer1 // defined by the Roi of imageViewer1. Algorithms.RoiToMask(mask, imageViewer1.Roi); HistogramReport report = Algorithms.Histogram(imageViewer1.Image, 256, new Range(0, 255), mask); // Plot the histogram on the graph int[] histogram = new int[256]; report.Histogram.CopyTo(histogram, 0); // Convert the int[] to a double[], which the graph requires. double[] histogramDouble = Array.ConvertAll <int, double>(histogram, delegate(int i) { return(i); }); simpleGraph1.PlotY(histogramDouble); } } }