public SegmentationForm(PictureBox pb) { InitializeComponent(); _pictureBox = pb; _segmentsComparer1 = new SegmentsComparer(); _segmentsComparer2 = new SegmentsComparer(); _segmentsComparerChartForm = new SegmentsComparerChartForm(); _segmentsComparerChartForm.Opacity = 0; _segmentsComparerChartForm.Show(); _segmentsComparerChartForm.Hide(); _segmentsComparerChartForm.Opacity = 1; }
private SegmentInfo SelectRegion(IDictionary <int, List <Point> > regions, PictureBox pictureBox, SegmentsComparer segmentsComparer, Point location) { if (pictureBox.Image == null) { return(null); } pictureBox.Image = segmentsComparer.AlgorithmGrayScale(GrayScale.FromRgb); SegmentInfo segmentInfo = null; List <Point> pointList = regions.Values.FirstOrDefault(points => points.Contains(location)); if (pointList != null) { var points = pointList.ToArray(); segmentInfo = new SegmentInfo(points); using (var g = Graphics.FromImage(pictureBox.Image)) { Pen pen = new Pen(Color.Fuchsia); if (points.Length < 3) { var point = points.First(); g.DrawEllipse(pen, point.X - 3, point.Y - 3, 6, 6); } else { g.DrawPolygon(pen, points); } } } return(segmentInfo); }