private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e) { if (imageViewer1.Roi.Count > 0 && imageViewer1.Roi[0].Type == ContourType.Line) { // Fill in the edge options structure from the controls on the form. EdgeOptions options = new EdgeOptions(); options.ColumnProcessingMode = (ColumnProcessingMode)Enum.Parse(typeof(ColumnProcessingMode), (string)smoothing.SelectedItem); options.InterpolationType = (InterpolationMethod)Enum.Parse(typeof(InterpolationMethod), (string)interpolationMethod.SelectedItem); options.KernelSize = (uint)kernelSize.Value; options.MinimumThreshold = (uint)minimumThreshold.Value; options.Polarity = (EdgePolaritySearchMode)Enum.Parse(typeof(EdgePolaritySearchMode), (string)polarity.SelectedItem); options.Width = (uint)width.Value; // Run the edge detection EdgeReport report = Algorithms.EdgeTool(imageViewer1.Image, imageViewer1.Roi, (EdgeProcess)Enum.Parse(typeof(EdgeProcess), (string)process.SelectedItem), options); // Overlay the edge positions imageViewer1.Image.Overlays.Default.Clear(); foreach (EdgeInfo edge in report.Edges) { imageViewer1.Image.Overlays.Default.AddOval(new OvalContour(edge.Position.X - 2, edge.Position.Y - 2, 5, 5), Rgb32Value.RedColor, DrawingMode.PaintValue); } // Graph the line profile and the gradient of the line. LineProfileReport lineProfile = Algorithms.LineProfile(imageViewer1.Image, imageViewer1.Roi); double[] profileData = new double[lineProfile.ProfileData.Count]; lineProfile.ProfileData.CopyTo(profileData, 0); double[] gradientData = new double[report.GradientInfo.Count]; report.GradientInfo.CopyTo(gradientData, 0); edgeDetectionGraph1.PlotData(profileData, gradientData); } }
private void LineProfile() { // Perform the line profile LineProfileReport report = Algorithms.LineProfile(imageViewer1.Image, imageViewer1.Roi); countBox.Text = report.ProfileData.Count.ToString(); // Graph the line profile. double[] profileData = new double[report.ProfileData.Count]; report.ProfileData.CopyTo(profileData, 0); simpleGraph1.PlotY(profileData); // Display the results minimumBox.Text = report.PixelRange.Minimum.ToString(); maximumBox.Text = report.PixelRange.Maximum.ToString(); meanBox.Text = report.Mean.ToString(); stdDevBox.Text = report.StandardDeviation.ToString(); }