Example #1
0
 public Snakes(int[][] mat)
 {
     m_mat      = mat;
     m_width    = mat.Length;
     m_height   = mat[0].Length;
     m_curve    = new SubpixelContour();
     m_averageD = 0.0;
 }
Example #2
0
        /// <summary>
        /// foamliu, 2009/02/07, 从临界区提取一个轮廓.
        ///
        /// </summary>
        /// <param name="contour"></param>
        private List <SubpixelContour> ExtractContourList()
        {
            List <SubpixelContour> contourList = new List <SubpixelContour>();
            int frontX = lastX, frontY = lastY;
            //int nextX, nextY;

            SubpixelContour contour = new SubpixelContour();

            //while ((FindNeighbor(frontX, frontY, NARROWBAND, out nextX, out nextY)))
            //{
            //    // foamliu, 2009/02/07, 如果两点间距过大应分为不同的轮廓.
            //    if (Math.Abs(frontX - nextX) + Math.Abs(frontY - nextY) > 50)
            //    {
            //        if (contour.ControlPoints.Count > 0)
            //            contourList.Add(contour);
            //        contour = new SubpixelContour();
            //    }

            //    m_alive[nextX][nextY] = ALIVE;
            //    contour.ControlPoints.Add(new SubpixelPoint(nextX, nextY));
            //    frontX = nextX;
            //    frontY = nextY;
            //}

            contourList.Add(contour);
            for (int y = 0; y < m_height; y++)
            {
                for (int x = 0; x < m_width; x++)
                {
                    if (m_alive[x][y] == NARROWBAND)
                    {
                        contour.Add(new DoublePoint(x, y));
                    }
                }
            }

            return(contourList);
        }