private void addCurvesForColumns(IEnumerable <DataColumn> columns, CurveOptions defaultCurveOptions = null)
 {
     using (_chartUpdater.UpdateTransaction(Chart))
     {
         columns.Each(x => AddCurveForColumn(x, defaultCurveOptions));
     }
 }
Пример #2
0
 private static void updateCurveOptions(CurveOptions curveOptions, ObservedCurveData observedCurve)
 {
     observedCurve.Color     = curveOptions.Color;
     observedCurve.LineStyle = curveOptions.LineStyle;
     observedCurve.Symbol    = curveOptions.Symbol;
     observedCurve.Visible   = curveOptions.Visible;
 }
        protected override void Context()
        {
            _observedDataCollection = new ObservedDataCollection();
            _displayPathMapper      = A.Fake <IQuantityPathToQuantityDisplayPathMapper>();
            _dimensionRepository    = A.Fake <IDimensionRepository>();
            sut              = new DataRepositoryToObservedCurveDataMapper(_displayPathMapper, _dimensionRepository);
            _observedData    = new DataRepository();
            _baseGrid        = new BaseGrid("Time", DomainHelperForSpecs.TimeDimensionForSpecs());
            _baseGrid.Values = new[] { 1.0f, 2.0f, 3.0f };

            _data                 = new DataColumn("Col", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), _baseGrid);
            _data.Values          = new[] { 10f, 20f, 30f };
            _data.DataInfo.Origin = ColumnOrigins.Observation;

            _observedData.Add(_data);

            _errorArithmetic        = new DataColumn("ErrorArithmetic", _data.Dimension, _baseGrid);
            _errorArithmetic.Values = new[] { 1.0f, 2.2f, 3.3f };
            _errorArithmetic.DataInfo.AuxiliaryType = AuxiliaryType.ArithmeticStdDev;

            _errorGeometric        = new DataColumn("ErrorGeometric", DomainHelperForSpecs.NoDimension(), _baseGrid);
            _errorGeometric.Values = new[] { 1.0f, 1.2f, 1.3f };
            _errorGeometric.DataInfo.AuxiliaryType = AuxiliaryType.GeometricStdDev;

            _observedDataCollection.AddObservedData(_observedData);

            _curveOptions           = _observedDataCollection.ObservedDataCurveOptionsFor(_data).CurveOptions;
            _curveOptions.Color     = Color.Aqua;
            _curveOptions.LineStyle = LineStyles.Dot;
            _curveOptions.Symbol    = Symbols.Diamond;
        }
Пример #4
0
        protected override async Task Context()
        {
            await base.Context();

            _curveOptions = new CurveOptions
            {
                Color = Color.Red
            };
        }
Пример #5
0
        protected override async Task Context()
        {
            await base.Context();

            _curveOptions = new CurveOptions
            {
                Color = Color.FromArgb(20, Color.CadetBlue)
            };
        }
Пример #6
0
        public static PaletteType ProcessImage(VisionImage image)
        {
            // Initialize the IVA_Data structure to pass results and coordinate systems.
            IVA_Data ivaData = new IVA_Data(3, 0);

            // Extract Color Plane
            using (VisionImage plane = new VisionImage(ImageType.U8, 7))
            {
                // Extract the green color plane and copy it to the main image.
                Algorithms.ExtractColorPlanes(image, ColorMode.Rgb, null, plane, null);
                Algorithms.Copy(plane, image);
            }

            // Creates a new, empty region of interest.
            Roi roi = new Roi();
            // Creates a new RectangleContour using the given values.
            RectangleContour vaRect = new RectangleContour(20, 20, 2552, 1904);

            roi.Add(vaRect);
            // Geometric Matching
            string       vaTemplateFile = $"{ @"./VisionModel/Polygon_20.5M/Mode.png"}";
            CurveOptions vaCurveOptions = new CurveOptions();

            vaCurveOptions.ColumnStepSize     = 15;
            vaCurveOptions.ExtractionMode     = ExtractionMode.NormalImage;
            vaCurveOptions.FilterSize         = EdgeFilterSize.Normal;
            vaCurveOptions.MaximumEndPointGap = 10;
            vaCurveOptions.MinimumLength      = 20;
            vaCurveOptions.RowStepSize        = 15;
            vaCurveOptions.Threshold          = 145;

            MatchGeometricPatternEdgeBasedOptions matchGPMOptions = new MatchGeometricPatternEdgeBasedOptions();

            matchGPMOptions.Advanced.ContrastMode  = ContrastMode.Original;
            matchGPMOptions.Advanced.MatchStrategy = GeometricMatchingSearchStrategy.Balanced;
            matchGPMOptions.MinimumMatchScore      = 800;
            matchGPMOptions.Mode = GeometricMatchModes.RotationInvariant;
            matchGPMOptions.NumberOfMatchesRequested = 1;
            double[] vaRangesMin = { -20, 0, 50, 0 };
            double[] vaRangesMax = { 20, 0, 200, 50 };
            matchGPMOptions.OcclusionRange = new Range(vaRangesMin[3], vaRangesMax[3]);
            matchGPMOptions.RotationAngleRanges.Add(new Range(vaRangesMin[0], vaRangesMax[0]));
            matchGPMOptions.RotationAngleRanges.Add(new Range(vaRangesMin[1], vaRangesMax[1]));
            matchGPMOptions.ScaleRange       = new Range(vaRangesMin[2], vaRangesMax[2]);
            matchGPMOptions.SubpixelAccuracy = true;

            gpm2Results = IVA_MatchGeometricPattern2(image, vaTemplateFile, vaCurveOptions, matchGPMOptions, ivaData, 2, roi);

            roi.Dispose();

            // Dispose the IVA_Data structure.
            ivaData.Dispose();

            // Return the palette type of the final image.
            return(PaletteType.Gray);
        }
Пример #7
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_curve);

            _context = new SimulationAnalysisContext(new[] { _dataRepository });
            _newModelCurveOptions = new CurveOptions {
                Color = Color.Aqua
            };
            A.CallTo(() => _curveOptionsMapper.MapToModel(_snapshot.CurveOptions)).Returns(_newModelCurveOptions);
        }
 protected override void Context()
 {
     base.Context();
     _defaultCurveOptions = new CurveOptions
     {
         Color           = Color.Fuchsia,
         LineThickness   = 2,
         VisibleInLegend = false,
         Symbol          = Symbols.Diamond,
         LineStyle       = LineStyles.DashDot
     };
 }
Пример #9
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_curve);

            _context = new SimulationAnalysisContext(null, new SnapshotContext())
            {
                RunSimulation = false
            };
            _newModelCurveOptions = new CurveOptions {
                Color = Color.Aqua
            };
            A.CallTo(() => _curveOptionsMapper.MapToModel(_snapshot.CurveOptions, A <SnapshotContext> ._)).Returns(_newModelCurveOptions);
        }
        protected override void Context()
        {
            base.Context();
            _firstPlotCurveOptions = new CurveOptions
            {
                Color           = Color.Black,
                LineThickness   = 1,
                VisibleInLegend = true
            };

            _defaultCurveOptions = new CurveOptions
            {
                Color           = Color.Fuchsia,
                LineThickness   = 2,
                VisibleInLegend = false
            };

            sut.AddCurveForColumn(_standardColumn, _firstPlotCurveOptions);
        }
        public Curve AddCurveForColumn(DataColumn dataColumn, CurveOptions defaultCurveOptions = null)
        {
            var curve = Chart.CreateCurve(dataColumn.BaseGrid, dataColumn, _curveNameDefinition(dataColumn), _dimensionFactory);

            if (Chart.HasCurve(curve.Id))
            {
                return(Chart.CurveBy(curve.Id));
            }

            Chart.UpdateCurveColorAndStyle(curve, dataColumn, AllDataColumns);

            if (defaultCurveOptions != null)
            {
                curve.CurveOptions.UpdateFrom(defaultCurveOptions);
            }

            Chart.AddCurve(curve);

            return(curve);
        }
Пример #12
0
        public Curve AddCurveForColumn(DataColumn dataColumn, CurveOptions defaultCurveOptions = null)
        {
            var(exists, curve) = createAndConfigureCurve(dataColumn, defaultCurveOptions);

            if (exists)
            {
                return(curve);
            }

            Chart.UpdateCurveColorAndStyle(curve, dataColumn, AllDataColumns);

            if (defaultCurveOptions != null)
            {
                curve.CurveOptions.UpdateFrom(defaultCurveOptions);
            }

            Chart.AddCurve(curve);

            return(curve);
        }
Пример #13
0
        public void FindMatches()
        {
            // Match the template in the image

            // Setup match options
            CurveOptions        curveOptions = new CurveOptions();
            GeometricMatchModes mode;

            if (rotationInvariant.Checked)
            {
                mode = GeometricMatchModes.RotationInvariant;
            }
            else
            {
                mode = GeometricMatchModes.ShiftInvariant;
            }
            if (occlusionInvariant.Checked)
            {
                mode |= GeometricMatchModes.OcclusionInvariant;
            }
            if (scaleInvariant.Checked)
            {
                mode |= GeometricMatchModes.ScaleInvariant;
            }
            matchOptions.Mode = mode;
            matchOptions.Advanced.MatchStrategy = GeometricMatchingSearchStrategy.Balanced;
            matchOptions.SubpixelAccuracy       = false;
            matchOptions.RotationAngleRanges.Add(new Range(0, 360));
            matchOptions.NumberOfMatchesRequested = (int)numMatches.Value;
            matchOptions.MinimumMatchScore        = (double)minScore.Value;

            // Match
            Collection <GeometricEdgeBasedPatternMatch> matches = Algorithms.MatchGeometricPatternEdgeBased(imageViewer.Image, templateImageViewer.Image, curveOptions, matchOptions, imageViewer.Roi);

            // Display results
            imageViewer.Image.Overlays.Default.Clear();
            foreach (GeometricEdgeBasedPatternMatch match in matches)
            {
                imageViewer.Image.Overlays.Default.AddPolygon(new PolygonContour(match.Corners), Rgb32Value.RedColor);
            }
        }
Пример #14
0
        protected override Task Context()
        {
            _curveOptionsMapper = A.Fake <CurveOptionsMapper>();
            sut = new ObservedDataCollectionMappper(_curveOptionsMapper);

            _observedDataRepository = DomainHelperForSpecs.ObservedData("ID").WithName("ObsData");
            _observedDataCollection = new Model.PopulationAnalyses.ObservedDataCollection();
            _observedDataCollection.ApplyGroupingToObservedData = true;
            _observedDataCollection.AddObservedData(_observedDataRepository);
            _firstObservedDataColumn  = _observedDataRepository.ObservationColumns().First();
            _observedDataCurveOptions = new ObservedDataCurveOptions
            {
                Caption  = "Obs Data Caption",
                ColumnId = _firstObservedDataColumn.Id
            };

            _observedDataCollection.AddCurveOptions(_observedDataCurveOptions);
            _snapshotCurveOptions = new CurveOptions();
            A.CallTo(() => _curveOptionsMapper.MapToSnapshot(_observedDataCurveOptions.CurveOptions)).Returns(_snapshotCurveOptions);
            return(_completed);
        }
Пример #15
0
 public ObservedDataCurveOptionsDTO(ObservedDataCurveOptions observedDataCurveOptions)
 {
     _observedDataCurveOptions = observedDataCurveOptions;
     _curveOptions             = _observedDataCurveOptions.CurveOptions;
     Rules.Add(GenericRules.NonEmptyRule <ObservedDataCurveOptionsDTO>(x => x.Caption));
 }
Пример #16
0
        public void AddCurvesWithSameColorForColumn(IReadOnlyList <DataColumn> dataColumnList, CurveOptions defaultCurveOptions = null)
        {
            var groupColor = Chart.SelectNewColor();

            foreach (var dataColumn in dataColumnList)
            {
                var(exists, curve) = createAndConfigureCurve(dataColumn, defaultCurveOptions);

                if (exists)
                {
                    continue;
                }

                if (defaultCurveOptions != null)
                {
                    curve.CurveOptions.UpdateFrom(defaultCurveOptions);
                }

                curve.Color = groupColor;
                curve.UpdateStyleForObservedData();

                Chart.AddCurve(curve);
            }
        }
Пример #17
0
        private (bool exists, Curve curve) createAndConfigureCurve(DataColumn dataColumn, CurveOptions defaultCurveOptions)
        {
            var curve = Chart.FindCurveWithSameData(dataColumn.BaseGrid, dataColumn);

            if (curve != null)
            {
                return(exists : true, Chart.CurveBy(curve.Id));
            }

            curve = Chart.CreateCurve(dataColumn.BaseGrid, dataColumn, _curveNameDefinition(dataColumn), _dimensionFactory);
            return(exists : false, curve);
        }
Пример #18
0
 public ObservedDataCurveOptions()
 {
     CurveOptions = new CurveOptions {
         LineStyle = LineStyles.None, Symbol = Symbols.Circle, Visible = true
     };
 }
Пример #19
0
        protected override async Task Because()
        {
            await sut.Serialize(_curveOptions, _fileName);

            _deserializedCurveOptions = await sut.Deserialize <CurveOptions>(_fileName);
        }
Пример #20
0
        private static Collection <GeometricEdgeBasedPatternMatch> IVA_MatchGeometricPattern2(VisionImage image,
                                                                                              string templatePath,
                                                                                              CurveOptions curveOptions,
                                                                                              MatchGeometricPatternEdgeBasedOptions matchOptions,
                                                                                              IVA_Data ivaData,
                                                                                              int stepIndex,
                                                                                              Roi roi)
        {
            // Geometric Matching (Edge Based)

            // Creates the image template.
            using (VisionImage imageTemplate = new VisionImage(ImageType.U8, 7))
            {
                // Read the image template.
                imageTemplate.ReadVisionFile(templatePath);

                Collection <GeometricEdgeBasedPatternMatch> gpmResults = Algorithms.MatchGeometricPatternEdgeBased(image, imageTemplate, curveOptions, matchOptions, roi);

                // Store the results in the data structure.

                // First, delete all the results of this step (from a previous iteration)
                Functions.IVA_DisposeStepResults(ivaData, stepIndex);

                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("# Matches", gpmResults.Count));

                for (int i = 0; i < gpmResults.Count; ++i)
                {
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.X Position (Pix.)", i + 1), gpmResults[i].Position.X));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Y Position (Pix.)", i + 1), gpmResults[i].Position.Y));

                    // If the image is calibrated, log the calibrated results.
                    if ((image.InfoTypes & InfoTypes.Calibration) != 0)
                    {
                        ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.X Position (World)", i + 1), gpmResults[i].CalibratedPosition.X));
                        ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Y Position (World)", i + 1), gpmResults[i].CalibratedPosition.Y));
                    }

                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Angle (degrees)", i + 1), gpmResults[i].Rotation));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Scale", i + 1), gpmResults[i].Scale));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Score", i + 1), gpmResults[i].Score));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Occlusion", i + 1), gpmResults[i].Occlusion));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Template Target Curve Score", i + 1), gpmResults[i].TemplateMatchCurveScore));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result(String.Format("Match {0}.Correlation Score", i + 1), gpmResults[i].CorrelationScore));
                }

                return(gpmResults);
            }
        }