示例#1
0
        private double haarX(int row, int column, int size)
        {
            double a = _integral.GetRectangleSum(column, row - size / 2,
                                                 column + size / 2 - 1, row - size / 2 + size - 1);

            double b = _integral.GetRectangleSum(column - size / 2, row - size / 2,
                                                 column - size / 2 + size / 2 - 1, row - size / 2 + size - 1);

            return((a - b) / 255.0);
        }
示例#2
0
        public void Compute(IntegralImage image)
        {
            int   b = (Size - 1) / 2 + 1;
            int   c = Size / 3;
            int   w = Size;
            float inv = 1f / (w * w);
            float Dxx, Dyy, Dxy;

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    // Get the image coordinates
                    int i = y * Step;
                    int j = x * Step;

                    // Compute response components
                    Dxx = ((int)image.GetRectangleSum(j - b, i - c + 1, j - b + w - 1, i - c + 2 * c - 1)
                           - (int)image.GetRectangleSum(j - c / 2, i - c + 1, j - c / 2 + c - 1, i - c + 2 * c - 1) * 3);

                    Dyy = ((int)image.GetRectangleSum(j - c + 1, i - b, j - c + 2 * c - 1, i - b + w - 1)
                           - (int)image.GetRectangleSum(j - c + 1, i - c / 2, j - c + 2 * c - 1, i - c / 2 + c - 1) * 3);

                    Dxy = ((int)image.GetRectangleSum(j + 1, i - c, j + c, i - 1)
                           + (int)image.GetRectangleSum(j - c, i + 1, j - 1, i + c)
                           - (int)image.GetRectangleSum(j - c, i - c, j - 1, i - 1)
                           - (int)image.GetRectangleSum(j + 1, i + 1, j + c, i + c));

                    // Normalize the filter responses with respect to their size
                    Dxx *= inv / 255f;
                    Dyy *= inv / 255f;
                    Dxy *= inv / 255f;

                    // Get the determinant of Hessian response & laplacian sign
                    Responses[y, x] = (Dxx * Dyy) - (0.9f * 0.9f * Dxy * Dxy);
                    Laplacian[y, x] = (Dxx + Dyy) >= 0 ? 1 : 0;
                }
            }
        }
示例#3
0
        public void GetRectangleSumTest(int x1, int y1, int x2, int y2, uint expectedSum)
        {
            uint sum = integralImage.GetRectangleSum(x1, y1, x2, y2);

            Assert.AreEqual(sum, expectedSum);
        }