Exemple #1
0
 /// <summary>
 /// Constructor with parameters
 /// </summary>
 /// <param name="thresh"></param>
 /// <param name="octaves"></param>
 /// <param name="init_sample"></param>
 /// <param name="img"></param>
 public FastHessian(float thresh, int octaves, int init_sample, IntegralImage img)
 {
     this.thresh      = thresh;
     this.octaves     = octaves;
     this.init_sample = init_sample;
     this.img         = img;
 }
Exemple #2
0
        public static IntegralImage FromImage(Bitmap image)
        {
            IntegralImage pic = new IntegralImage(image.Width, image.Height);

            float rowsum = 0;

            for (int x = 0; x < image.Width; x++)
            {
                Color c = image.GetPixel(x, 0);
                rowsum   += (cR * c.R + cG * c.G + cB * c.B) / 255f;
                pic[0, x] = rowsum;
            }


            for (int y = 1; y < image.Height; y++)
            {
                rowsum = 0;
                for (int x = 0; x < image.Width; x++)
                {
                    Color c = image.GetPixel(x, y);
                    rowsum += (cR * c.R + cG * c.G + cB * c.B) / 255f;

                    // integral image is rowsum + value above
                    pic[y, x] = rowsum + pic[y - 1, x];
                }
            }

            return(pic);
        }
 /// <summary>
 /// Constructor with parameters
 /// </summary>
 /// <param name="thresh"></param>
 /// <param name="octaves"></param>
 /// <param name="init_sample"></param>
 /// <param name="img"></param>
 public FastHessian(float thresh, int octaves, int init_sample, IntegralImage img)
 {
     this.thresh = thresh;
       this.octaves = octaves;
       this.init_sample = init_sample;
       this.img = img;
 }
Exemple #4
0
    public static IntegralImage FromImage(Bitmap image)
    {
      IntegralImage pic = new IntegralImage(image.Width, image.Height);

      float rowsum = 0;
      for (int x = 0; x < image.Width; x++)
      {
        Color c = image.GetPixel(x, 0);
        rowsum += (cR * c.R + cG * c.G + cB * c.B) / 255f;
        pic[0, x] = rowsum;
      }


      for (int y = 1; y < image.Height; y++)
      {
        rowsum = 0;
        for (int x = 0; x < image.Width; x++)
        {
          Color c = image.GetPixel(x, y);
          rowsum += (cR * c.R + cG * c.G + cB * c.B) / 255f;

          // integral image is rowsum + value above        
          pic[y, x] = rowsum + pic[y - 1, x];
        }
      }

      return pic;
    }
        /// <summary>
        /// Build descriptor vector for each interest point in the supplied list
        /// </summary>
        /// <param name="img"></param>
        /// <param name="ipts"></param>
        /// <param name="upright"></param>
        public void DescribeInterestPoints(List <IPoint> ipts, bool upright, bool extended, IntegralImage img)
        {
            if (ipts.Count == 0)
            {
                return;
            }
            this.img = img;

            foreach (IPoint ip in ipts)
            {
                // determine descriptor size
                if (extended)
                {
                    ip.descriptorLength = 128;
                }
                else
                {
                    ip.descriptorLength = 64;
                }

                // if we want rotation invariance get the orientation
                if (!upright)
                {
                    GetOrientation(ip);
                }

                // Extract SURF descriptor
                GetDescriptor(ip, upright, extended);
            }
        }
        public static IntegralImage FromImage(Bitmap image)
        {
            IntegralImage pic = new IntegralImage(image.Width, image.Height);

              float rowsum = 0;
              //for (int x = 0; x < image.Width; x++)
              //{
              //  Color c = image.GetPixel(x, 0);
              //  rowsum += (cR * c.R + cG * c.G + cB * c.B) / 255f;
              //  pic[0, x] = rowsum;
              //}

              //for (int y = 1; y < image.Height; y++)
              //{
              //  rowsum = 0;
              //  for (int x = 0; x < image.Width; x++)
              //  {
              //    Color c = image.GetPixel(x, y);
              //    rowsum += (cR * c.R + cG * c.G + cB * c.B) / 255f;

              //    // integral image is rowsum + value above
              //    pic[y, x] = rowsum + pic[y - 1, x];
              //  }
              //}

              BitmapData dataIn = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
              unsafe
              {
              byte* pIn = (byte*)(dataIn.Scan0.ToPointer());
              for (int y = 0; y < dataIn.Height; y++)
              {
              rowsum = 0;
              for (int x = 0; x < dataIn.Width; x++)
              {
                  int cb = (byte)(pIn[0]);
                  int cg = (byte)(pIn[1]);
                  int cr = (byte)(pIn[2]);

                  // 0 1 2代表的次序是B G R
                  rowsum += (cR * cr + cG * cg + cB * cb) / 255f;
                  // integral image is rowsum + value above
                  if (y == 0)
                      pic[0, x] = rowsum;
                  else
                      pic[y, x] = rowsum + pic[y - 1, x];

                  pIn += 3;
              }
              pIn += dataIn.Stride - dataIn.Width * 3;
              }
              }
              image.UnlockBits(dataIn);

              return pic;
        }
        /// <summary>
        /// Build descriptor vector for each interest point in the supplied list
        /// </summary>
        /// <param name="img"></param>
        /// <param name="ipts"></param>
        /// <param name="upright"></param>
        public void DescribeInterestPoints(List<IPoint> ipts, bool upright, bool extended, IntegralImage img)
        {
            if (ipts.Count == 0) return;
              this.img = img;

              foreach (IPoint ip in ipts)
              {
            // determine descriptor size
            if (extended) ip.descriptorLength = 128;
            else ip.descriptorLength = 64;

            // if we want rotation invariance get the orientation
            if (!upright) GetOrientation(ip);

            // Extract SURF descriptor
            GetDescriptor(ip, upright, extended);
              }
        }
 /// <summary>
 /// Static one-call do it all function
 /// </summary>
 /// <param name="img"></param>
 /// <param name="ipts"></param>
 /// <param name="extended"></param>
 /// <param name="upright"></param>
 public static void DecribeInterestPoints(List<IPoint> ipts, bool upright, bool extended, IntegralImage img)
 {
     SurfDescriptor des = new SurfDescriptor();
       des.DescribeInterestPoints(ipts, upright, extended, img);
 }
 /// <summary>
 /// Static one-call do it all method
 /// </summary>
 /// <param name="thresh"></param>
 /// <param name="octaves"></param>
 /// <param name="init_sample"></param>
 /// <param name="img"></param>
 /// <returns></returns>
 public static List<IPoint> getIpoints(float thresh, int octaves, int init_sample, IntegralImage img)
 {
     FastHessian fh = new FastHessian(thresh, octaves, init_sample, img);
       return fh.getIpoints();
 }
Exemple #10
0
        /// <summary>
        /// Static one-call do it all method
        /// </summary>
        /// <param name="thresh"></param>
        /// <param name="octaves"></param>
        /// <param name="init_sample"></param>
        /// <param name="img"></param>
        /// <returns></returns>
        public static List <IPoint> getIpoints(float thresh, int octaves, int init_sample, IntegralImage img)
        {
            FastHessian fh = new FastHessian(thresh, octaves, init_sample, img);

            return(fh.getIpoints());
        }
        /// <summary>
        /// Static one-call do it all function
        /// </summary>
        /// <param name="img"></param>
        /// <param name="ipts"></param>
        /// <param name="extended"></param>
        /// <param name="upright"></param>
        public static void DecribeInterestPoints(List <IPoint> ipts, bool upright, bool extended, IntegralImage img)
        {
            SurfDescriptor des = new SurfDescriptor();

            des.DescribeInterestPoints(ipts, upright, extended, img);
        }