Ejemplo n.º 1
0
        private List <System.Drawing.PointF> ExtractPoints(Emgu.CV.Image <Gray, byte> channel)
        {
            IncWeightedAverage[] iwas = new IncWeightedAverage[channel.Width];

            // Search per row
            byte[] d      = channel.Bytes;
            int    stride = d.Length / channel.Height;
            int    h      = channel.Height;
            int    w      = channel.Width;

            // See http://www.cse.iitm.ac.in/~cs670/book/node57.html

            if (_search_direction == ESearchDirection.TopDown)
            {
                for (int r = 0; r < h; ++r)
                {
                    ProcessRow(iwas, d, stride, w, r);
                }
            }
            else
            {
                for (int r = h - 1; r >= 0; --r)
                {
                    ProcessRow(iwas, d, stride, w, r);
                }
            }

            List <System.Drawing.PointF> pixels = new List <System.Drawing.PointF>();

            for (int i = 0; i < w; ++i)
            {
                if (iwas[i].iwa > 0)
                {
                    pixels.Add(new System.Drawing.PointF(i, (float)iwas[i].iwa));
                }
            }

            return(pixels);
        }
Ejemplo n.º 2
0
    private List<System.Drawing.PointF> ExtractPoints(Emgu.CV.Image<Gray, byte> channel) {
      IncWeightedAverage[] iwas = new IncWeightedAverage[channel.Width];

      // Search per row
      byte[] d = channel.Bytes;
      int stride = d.Length / channel.Height;
      int h = channel.Height;
      int w = channel.Width;

      // See http://www.cse.iitm.ac.in/~cs670/book/node57.html

      if (_search_direction == ESearchDirection.TopDown)
      {
        for (int r = 0; r < h; ++r)
        {
          ProcessRow(iwas, d, stride, w, r);
        }
      }
      else
      {
        for (int r = h - 1; r >= 0; --r)
        {
          ProcessRow(iwas, d, stride, w, r);
        }
      }

      List<System.Drawing.PointF> pixels = new List<System.Drawing.PointF>();
      for (int i = 0; i < w; ++i) {
        if (iwas[i].iwa > 0) {
          pixels.Add(new System.Drawing.PointF(i, (float)iwas[i].iwa));
        }
      }

      return pixels;
    }
Ejemplo n.º 3
0
 private void ProcessRow(IncWeightedAverage[] iwas, byte[] d, int stride, int w, int r)
 {
   int offset = stride * r;
   for (int c = 0; c < w; ++c) {
     byte i = d[offset + c];
     if (i < _threshold) {
       iwas[c].stop |= iwas[c].weights > 0;
     } else {
       if (!iwas[c].stop)
         iwas[c].Update(r, i);
     }
   }
 }