Ejemplo n.º 1
0
        public double Apply(IntegralImage image, int x)
        {
            Func <double, double, double> comparer = SubtractLog;

            switch (m_type)
            {
            case 0:
                return(Filter0(image, x, m_y, m_width, m_height, comparer));

            case 1:
                return(Filter1(image, x, m_y, m_width, m_height, comparer));

            case 2:
                return(Filter2(image, x, m_y, m_width, m_height, comparer));

            case 3:
                return(Filter3(image, x, m_y, m_width, m_height, comparer));

            case 4:
                return(Filter4(image, x, m_y, m_width, m_height, comparer));

            case 5:
                return(Filter5(image, x, m_y, m_width, m_height, comparer));
            }
            return(0.0);
        }
Ejemplo n.º 2
0
        // oooooooooooooooo
        // oooooooooooooooo
        // oooooooooooooooo
        // oooooooooooooooo
        public static double Filter0(IntegralImage image, int x, int y, int w, int h, Func <double, double, double> cmp)
        {
            //Debug.Assert(x >= 0);
            //Debug.Assert(y >= 0);
            //Debug.Assert(w >= 1);
            //Debug.Assert(h >= 1);

            double a = image.Area(x, y, x + w - 1, y + h - 1);
            double b = 0;

            return(cmp(a, b));
        }
Ejemplo n.º 3
0
        public int CalculateSubfingerprint(IntegralImage image, int offset)
        {
            uint bits = 0;

            for (int i = 0; i < m_num_classifiers; i++)
            {
                //for (int i = m_num_classifiers - 1; i >= 0; i--) {
                // TODO: cast uint
                bits = (bits << 2) | GrayCode[m_classifiers[i].Classify(image, offset)];
                //bits = (bits << 2) | m_classifiers[i].Classify(image, offset);
            }
            return((int)bits);
        }
Ejemplo n.º 4
0
        // .......ooooooooo
        // .......ooooooooo
        // ooooooo.........
        // ooooooo.........
        public static double Filter3(IntegralImage image, int x, int y, int w, int h, Func <double, double, double> cmp)
        {
            //Debug.Assert(x >= 0);
            //Debug.Assert(y >= 0);
            //Debug.Assert(w >= 1);
            //Debug.Assert(h >= 1);

            int w_2 = w / 2;
            int h_2 = h / 2;

            double a = image.Area(x, y + h_2, x + w_2 - 1, y + h - 1) +
                       image.Area(x + w_2, y, x + w - 1, y + h_2 - 1);
            double b = image.Area(x, y, x + w_2 - 1, y + h_2 - 1) +
                       image.Area(x + w_2, y + h_2, x + w - 1, y + h - 1);

            return(cmp(a, b));
        }
Ejemplo n.º 5
0
        public int[] Calculate(Image image)
        {
            int length = image.Rows - m_max_filter_width + 1;

            if (length <= 0)
            {
                //DEBUG() << "Chromaprint::FingerprintCalculator::Calculate() -- Not "
                //		<< "enough data. Image has " << image.NumRows() << " rows, "
                //		<< "needs at least " << m_max_filter_width << " rows.\n";
                return(null);
            }
            IntegralImage integral_image = new IntegralImage(image);
            var           fingerprint    = new int[length];

            for (int i = 0; i < length; i++)
            {
                fingerprint[i] = CalculateSubfingerprint(integral_image, i);
            }
            return(fingerprint);
        }