Esempio n. 1
0
        public List<double[]> extract(Bitmap image, string detector)
        {
            SCD_Descriptor scdLocal = new SCD_Descriptor();
            Bitmap bmpImage = new Bitmap(image);

            createPoints pointsCreator = new createPoints();
            List<Keypoint> keypointsList = null;
            if (detector == "SURF")
                keypointsList = pointsCreator.usingSurf(image);
            else if (detector == "SIFT")
                keypointsList = pointsCreator.usingSift(image);
            else
                throw new Exception("Cannot recognize Detector");

            #region SCD_Local
            Rectangle cloneRect;
            Bitmap bmpCrop;
            double[] scdDescriptor = new double[256];
            List<double[]> tilesDescriptors = new List<double[]>();

            foreach (Keypoint myKeypoint in keypointsList)
            {
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

                scdLocal.Apply(new Bitmap(bmpCrop), 256, 0);
                scdDescriptor = scdLocal.Norm4BitHistogram;
                tilesDescriptors.Add(scdDescriptor);
            }
            #endregion

            return tilesDescriptors;
        }
Esempio n. 2
0
        public List <double[]> extract(Bitmap image, string detector)
        {
            CEDD   cedd     = new CEDD();
            Bitmap bmpImage = new Bitmap(image);

            createPoints    pointsCreator = new createPoints();
            List <Keypoint> keypointsList = null;

            if (detector == "SURF")
            {
                keypointsList = pointsCreator.usingSurf(image);
            }
            else if (detector == "SIFT")
            {
                keypointsList = pointsCreator.usingSift(image);
            }
            else
            {
                throw new Exception("Cannot recognize Detector");
            }

            #region LoCATe
            Rectangle       cloneRect;
            double[]        ceddDescriptor;
            List <double[]> tilesDescriptors = new List <double[]>();

            Object thisLock = new Object();
            Parallel.ForEach(keypointsList, myKeypoint =>
            {
                Bitmap bmpCrop;
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                lock (thisLock)
                {
                    bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));
                }

                ceddDescriptor = cedd.Apply(new Bitmap(bmpCrop));
                lock (thisLock)
                {
                    tilesDescriptors.Add(ceddDescriptor);
                }
            });

            //foreach (Keypoint myKeypoint in keypointsList)
            //{
            //    cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
            //    bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

            //    ceddDescriptor = cedd.Apply(new Bitmap(bmpCrop));

            //}
            #endregion

            return(tilesDescriptors);
        }
Esempio n. 3
0
        public List <double[]> extract(Bitmap image, string detector)
        {
            CLD_Descriptor cldLocal = new CLD_Descriptor();
            Bitmap         bmpImage = new Bitmap(image);

            createPoints    pointsCreator = new createPoints();
            List <Keypoint> keypointsList = null;

            if (detector == "SURF")
            {
                keypointsList = pointsCreator.usingSurf(image);
            }
            else if (detector == "SIFT")
            {
                keypointsList = pointsCreator.usingSift(image);
            }
            else
            {
                throw new Exception("Cannot recognize Detector");
            }

            #region CLD_Local
            Rectangle       cloneRect;
            Bitmap          bmpCrop;
            double[]        result;
            int[]           Y  = new int[64];
            int[]           Cb = new int[64];
            int[]           Cr = new int[64];
            List <double[]> tilesDescriptors = new List <double[]>();
            foreach (Keypoint myKeypoint in keypointsList)
            {
                result    = new double[3 * 64];
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                bmpCrop   = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

                cldLocal.Apply(new Bitmap(bmpCrop));
                Y  = cldLocal.YCoeff;
                Cb = cldLocal.CbCoeff;
                Cr = cldLocal.CrCoeff;
                for (int i = 0; i < 64; i++)
                {
                    result[i]          = Y[i];
                    result[64 + i]     = Cb[i];
                    result[2 * 64 + i] = Cr[i];
                }
                tilesDescriptors.Add(result);
            }
            #endregion

            return(tilesDescriptors);
        }
Esempio n. 4
0
        public List<double[]> extract(Bitmap image, string detector)
        {
            CEDD cedd = new CEDD();
            Bitmap bmpImage = new Bitmap(image);

            createPoints pointsCreator = new createPoints();
            List<Keypoint> keypointsList = null;
            if (detector == "SURF")
                keypointsList = pointsCreator.usingSurf(image);
            else if (detector == "SIFT")
                keypointsList = pointsCreator.usingSift(image);
            else
                throw new Exception("Cannot recognize Detector");

            #region LoCATe
            Rectangle cloneRect;
            double[] ceddDescriptor;
            List<double[]> tilesDescriptors = new List<double[]>();

            Object thisLock = new Object();
            Parallel.ForEach(keypointsList, myKeypoint =>
            {
                Bitmap bmpCrop;
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                lock (thisLock)
                {
                    bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));
                }

                ceddDescriptor = cedd.Apply(new Bitmap(bmpCrop));
                lock (thisLock)
                {
                    tilesDescriptors.Add(ceddDescriptor);
                }
            });

            //foreach (Keypoint myKeypoint in keypointsList)
            //{
            //    cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
            //    bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

            //    ceddDescriptor = cedd.Apply(new Bitmap(bmpCrop));

            //}
            #endregion

            return tilesDescriptors;
        }
Esempio n. 5
0
        public List<double[]> extract(Bitmap image, string detector)
        {
            CLD_Descriptor cldLocal = new CLD_Descriptor();
            Bitmap bmpImage = new Bitmap(image);

            createPoints pointsCreator = new createPoints();
            List<Keypoint> keypointsList = null;
            if (detector == "SURF")
                keypointsList = pointsCreator.usingSurf(image);
            else if (detector == "SIFT")
                keypointsList = pointsCreator.usingSift(image);
            else
                throw new Exception("Cannot recognize Detector");

            #region CLD_Local
            Rectangle cloneRect;
            Bitmap bmpCrop;
            double[] result;
            int[] Y = new int[64];
            int[] Cb = new int[64];
            int[] Cr = new int[64];
            List<double[]> tilesDescriptors = new List<double[]>();
            foreach (Keypoint myKeypoint in keypointsList)
            {
                result = new double[3 * 64];
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                bmpCrop = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

                cldLocal.Apply(new Bitmap(bmpCrop));
                Y = cldLocal.YCoeff;
                Cb = cldLocal.CbCoeff;
                Cr = cldLocal.CrCoeff;
                for (int i = 0; i < 64; i++ )
                {
                    result[i] = Y[i];
                    result[64 + i] = Cb[i];
                    result[2 * 64 + i] = Cr[i];

                }
                tilesDescriptors.Add(result);
            }
            #endregion

            return tilesDescriptors;
        }
Esempio n. 6
0
        public List <double[]> extract(Bitmap image, string detector)
        {
            SCD_Descriptor scdLocal = new SCD_Descriptor();
            Bitmap         bmpImage = new Bitmap(image);

            createPoints    pointsCreator = new createPoints();
            List <Keypoint> keypointsList = null;

            if (detector == "SURF")
            {
                keypointsList = pointsCreator.usingSurf(image);
            }
            else if (detector == "SIFT")
            {
                keypointsList = pointsCreator.usingSift(image);
            }
            else
            {
                throw new Exception("Cannot recognize Detector");
            }

            #region SCD_Local
            Rectangle       cloneRect;
            Bitmap          bmpCrop;
            double[]        scdDescriptor    = new double[256];
            List <double[]> tilesDescriptors = new List <double[]>();

            foreach (Keypoint myKeypoint in keypointsList)
            {
                cloneRect = new Rectangle((int)(myKeypoint.X - (int)myKeypoint.Size / 2), (int)(myKeypoint.Y - (int)myKeypoint.Size / 2), (int)myKeypoint.Size, (int)myKeypoint.Size);
                bmpCrop   = new Bitmap(bmpImage.Clone(cloneRect, bmpImage.PixelFormat));

                scdLocal.Apply(new Bitmap(bmpCrop), 256, 0);
                scdDescriptor = scdLocal.Norm4BitHistogram;
                tilesDescriptors.Add(scdDescriptor);
            }
            #endregion

            return(tilesDescriptors);
        }