Beispiel #1
0
 private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
 {
     if (imageViewer1.Roi.Count > 0)
     {
         DoImageToArray();
     }
 }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 // When a region is available, the Learn button is enabled.
 private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
 {
     if (imageViewer1.Roi.Count > 0)
     {
         learnPatternButton.Enabled = true;
     }
     else
     {
         learnPatternButton.Enabled = false;
     }
 }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
 private void imageViewer_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
 {
 }
Beispiel #6
0
 private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
 {
     DisplayColorDistance();
 }
Beispiel #7
0
 void Roi_ContoursChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
 {
     learnPatternButton.Enabled = imageViewerMain.Roi.Count > 0;
 }