Пример #1
0
 internal static extern Seq cvApproxPoly(
     Seq src_seq,
     int header_size,
     MemStorage storage,
     PolygonApproximation method,
     double parameter,
     int parameter2);
Пример #2
0
        /// <summary>
        /// Change mokkan extraction parameters
        /// </summary>
        private void ChangeExtraction()
        {
            if (_init)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            List <Boundary> bounds = MokkanExtraction.BoundaryTracking(_binBmp, _bndRec);

            // get top regions
            List <int> tops = new List <int>();

            GetTopAreas(bounds, _mokkanNum, tops);

            // number of regions
            int n = Math.Min(_mokkanNum, tops.Count - 1);

            DrawPolygon reducePolygon;

            MkaMokkanInfo.LastRBangou -= _list.Count;
            _list.Clear();
            Bitmap   ret = (Bitmap)_oriBmp.Clone();
            Graphics g   = Graphics.FromImage(ret);

            g.DrawRectangle(Pens.Red, _bndRec);

            for (int i = 0; i < n; i++)
            {
                if (_tolerance == 0)
                {
                    reducePolygon = new DrawPolygon();
                    foreach (PointF p in bounds[tops[i]].Points)
                    {
                        reducePolygon.AddPoint(new Point((int)p.X, (int)p.Y));
                    }
                }
                else
                {
                    // get reduce polygon
                    reducePolygon = PolygonApproximation.ReductionPolygon(bounds[tops[i]].Points, _tolerance);
                }

                _list.Add(reducePolygon);
                MkaMokkanInfo.LastRBangou++;

                g.DrawPolygon(_pen, bounds[tops[i]].Points.ToArray());
                g.FillPolygon(_brush, bounds[tops[i]].Points.ToArray());
            }

            g.Dispose();
            bounds.Clear();
            tops.Clear();

            if (picImageView.Image != null)
            {
                picImageView.Image.Dispose();
            }
            picImageView.Image = ret;

            this.Cursor = Cursors.Default;
        }