Beispiel #1
0
        public static void find_best_patch_inside_region_test(
                          classimage_mono image,
                          ref uint ubest, ref uint vbest, ref float evbest,
                          uint BOXSIZE, uint ustart, uint vstart,
                          uint ufinish, uint vfinish)
        {
            long corr;
            long corrmax = MIN_PATCH_DIFFERENCE * BOXSIZE * BOXSIZE / 2;
            int tx, ty, bx, by;

            for (int x = (int)ustart; x < ufinish; x++)
            {
                for (int y = (int)vstart; y < vfinish; y++)
                {
                    tx = (int)(x - (BOXSIZE - 1) / 2);
                    ty = (int)(y - (BOXSIZE - 1) / 2);
                    bx = (int)(tx + BOXSIZE);
                    by = (int)(ty + BOXSIZE);
                    long leftval = image.getIntegral(tx, ty, x, by);
                    long rightval = image.getIntegral(x, ty, bx, by);
                    long topval = image.getIntegral(tx, ty, bx, y);
                    long bottomval = image.getIntegral(tx, y, bx, by);

                    corr = Math.Abs(leftval - rightval) +
                           Math.Abs(topval - bottomval) + 
                           Math.Abs(leftval - topval) +
                           Math.Abs(rightval - topval) +
                           Math.Abs(leftval - bottomval) +
                           Math.Abs(rightval - bottomval);
                    if (corr > corrmax)
                    {
                        corrmax = corr;
                        ubest = (uint)x;
                        vbest = (uint)y;
                        evbest = corr;
                    }
                    

                }
            }
        }