Esempio n. 1
0
        public static float[] imageFeatures(Image <Bgr, byte> src, int w = 20, int h = 20)
        {
            Image <Bgr, float> copy = src.Convert <Bgr, float>();

            copy = copy.Resize(w, h, Emgu.CV.CvEnum.Inter.Linear, false);
            Mat[] channels = copy.Mat.Split();
            int   n        = copy.Rows * copy.Cols;

            float[] vectorOfFeature = new float[n * 3];
            for (int i = 0; i < channels.Length; i++)
            {
                Mat           c    = channels[0].Reshape(1, n);
                MatND <float> temp = new MatND <float>(n);
                c.CopyTo(temp);
                float[] partition = (float[])temp.ManagedArray;
                partition.CopyTo(vectorOfFeature, i * n);
                c.Dispose();
                temp.Dispose();
            }
            channels = null;
            copy.Dispose();
            return(vectorOfFeature);
        }