Search in sources :

Example 26 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class TestTldVarianceFilter method selectThreshold.

@Test
public void selectThreshold() {
    GrayU8 image = new GrayU8(50, 80);
    ImageMiscOps.fillUniform(image, rand, 0, 200);
    TldVarianceFilter alg = new TldVarianceFilter(GrayU8.class);
    alg.setImage(image);
    alg.selectThreshold(new ImageRectangle(10, 8, 21, 33));
    double found = alg.getThresholdLower();
    double expected = computeVariance(image, 10, 8, 21, 33) / 2.0;
    assertEquals(expected, found, 1e-8);
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Test(org.junit.Test)

Example 27 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class IntegralImageOps method print.

/**
 * Prints out the kernel.
 *
 * @param kernel THe kernel which is to be printed.
 */
public static void print(IntegralKernel kernel) {
    int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
    for (ImageRectangle k : kernel.blocks) {
        if (k.x0 < x0)
            x0 = k.x0;
        if (k.y0 < y0)
            y0 = k.y0;
        if (k.x1 > x1)
            x1 = k.x1;
        if (k.y1 > y1)
            y1 = k.y1;
    }
    int w = x1 - x0;
    int h = y1 - y0;
    int[] sum = new int[w * h];
    for (int i = 0; i < kernel.blocks.length; i++) {
        ImageRectangle r = kernel.blocks[i];
        int value = kernel.scales[i];
        for (int y = r.y0; y < r.y1; y++) {
            int yy = y - y0;
            for (int x = r.x0; x < r.x1; x++) {
                int xx = x - x0;
                sum[yy * w + xx] += value;
            }
        }
    }
    System.out.println("IntegralKernel: TL = (" + (x0 + 1) + "," + (y0 + 1) + ") BR=(" + x1 + "," + y1 + ")");
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            System.out.printf("%4d ", sum[y * w + x]);
        }
        System.out.println();
    }
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle)

Example 28 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class ImplIntegralImageOps method convolveSparse.

public static float convolveSparse(GrayF32 integral, IntegralKernel kernel, int x, int y) {
    float ret = 0;
    int N = kernel.getNumBlocks();
    for (int i = 0; i < N; i++) {
        ImageRectangle r = kernel.blocks[i];
        ret += block_zero(integral, x + r.x0, y + r.y0, x + r.x1, y + r.y1) * kernel.scales[i];
    }
    return ret;
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle)

Example 29 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class ImplIntegralImageOps method convolveSparse.

public static double convolveSparse(GrayF64 integral, IntegralKernel kernel, int x, int y) {
    double ret = 0;
    int N = kernel.getNumBlocks();
    for (int i = 0; i < N; i++) {
        ImageRectangle r = kernel.blocks[i];
        ret += block_zero(integral, x + r.x0, y + r.y0, x + r.x1, y + r.y1) * kernel.scales[i];
    }
    return ret;
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle)

Example 30 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class ImplIntegralImageOps method convolve.

public static void convolve(GrayS32 integral, IntegralKernel kernel, GrayS32 output) {
    for (int y = 0; y < integral.height; y++) {
        for (int x = 0; x < integral.width; x++) {
            int total = 0;
            for (int i = 0; i < kernel.blocks.length; i++) {
                ImageRectangle b = kernel.blocks[i];
                total += block_zero(integral, x + b.x0, y + b.y0, x + b.x1, y + b.y1) * kernel.scales[i];
            }
            output.set(x, y, total);
        }
    }
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle)

Aggregations

ImageRectangle (boofcv.struct.ImageRectangle)43 Test (org.junit.Test)15 GrayU8 (boofcv.struct.image.GrayU8)10 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)3 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)3 GImageGray (boofcv.core.image.GImageGray)3 ImageGray (boofcv.struct.image.ImageGray)3 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 GrayS32 (boofcv.struct.image.GrayS32)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)1 FastQueue (org.ddogleg.struct.FastQueue)1 GrowQueue_F64 (org.ddogleg.struct.GrowQueue_F64)1