Search in sources :

Example 91 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImplAverageDownSample method horizontal_3_to_2.

/**
 * The division will not be along pixels and symmetries are avoided
 */
@Test
public void horizontal_3_to_2() throws InvocationTargetException, IllegalAccessException {
    List<Method> methods = find("horizontal");
    for (Method m : methods) {
        Class typeSrc = m.getParameterTypes()[0];
        Class typeDst = m.getParameterTypes()[1];
        // System.out.println(typeSrc+"   "+typeDst);
        ImageGray src = GeneralizedImageOps.createSingleBand(typeSrc, 9, 3);
        ImageGray dst = GeneralizedImageOps.createSingleBand(typeDst, 4, 3);
        fillHorizontal(src);
        m.invoke(null, src, dst);
        for (int y = 0; y < src.height; y++) {
            assertEquals(0.6666667f, GeneralizedImageOps.get(dst, 0, y), 1e-4f);
            assertEquals(2.8888889f, GeneralizedImageOps.get(dst, 1, y), 1e-4f);
            assertEquals(5.1111111f, GeneralizedImageOps.get(dst, 2, y), 1e-4f);
            assertEquals(7.3333333f, GeneralizedImageOps.get(dst, 3, y), 1e-4f);
        }
    }
    assertEquals(4, methods.size());
}
Also used : ImageGray(boofcv.struct.image.ImageGray) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 92 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImplAverageDownSample method vertical_3_to_2.

@Test
public void vertical_3_to_2() throws InvocationTargetException, IllegalAccessException {
    List<Method> methods = find("vertical");
    for (Method m : methods) {
        Class typeSrc = m.getParameterTypes()[0];
        Class typeDst = m.getParameterTypes()[1];
        // System.out.println(typeSrc+"   "+typeDst);
        ImageGray src = GeneralizedImageOps.createSingleBand(typeSrc, 3, 9);
        ImageGray dst = GeneralizedImageOps.createSingleBand(typeDst, 3, 4);
        fillVertical(src);
        m.invoke(null, src, dst);
        double[] expected;
        if (dst.getDataType().isInteger()) {
            expected = new double[] { 1, 3, 5, 7 };
        } else {
            expected = new double[] { 0.6666667f, 2.8888889f, 5.1111111f, 7.3333333f };
        }
        for (int x = 0; x < src.width; x++) {
            for (int y = 0; y < dst.height; y++) {
                assertEquals(expected[y], GeneralizedImageOps.get(dst, x, y), 1e-4);
            }
        }
    }
    assertEquals(4, methods.size());
}
Also used : ImageGray(boofcv.struct.image.ImageGray) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 93 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImplAverageDownSample2 method compareToNaive.

public void compareToNaive(Method m) {
    Class inputType = m.getParameterTypes()[0];
    Class outputType = m.getParameterTypes()[1];
    ImageGray input = GeneralizedImageOps.createSingleBand(inputType, width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 100);
    int downWidth = AverageDownSampleOps.downSampleSize(width, 2);
    int downHeight = AverageDownSampleOps.downSampleSize(height, 2);
    ImageGray found = GeneralizedImageOps.createSingleBand(outputType, downWidth, downHeight);
    ImageGray expected = GeneralizedImageOps.createSingleBand(outputType, downWidth, downHeight);
    try {
        m.invoke(null, input, found);
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
    naive(input, 2, expected);
    BoofTesting.assertEquals(found, expected, 1e-4);
}
Also used : ImageGray(boofcv.struct.image.ImageGray) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 94 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestImplAverageDownSampleN method compareToNaive.

public void compareToNaive(Method m) {
    Class inputType = m.getParameterTypes()[0];
    Class outputType = m.getParameterTypes()[2];
    ImageGray input = GeneralizedImageOps.createSingleBand(inputType, width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 100);
    for (int region = 1; region <= 5; region++) {
        int downWidth = width % region == 0 ? width / region : width / region + 1;
        int downHeight = height % region == 0 ? height / region : height / region + 1;
        ImageGray found = GeneralizedImageOps.createSingleBand(outputType, downWidth, downHeight);
        ImageGray expected = GeneralizedImageOps.createSingleBand(outputType, downWidth, downHeight);
        try {
            m.invoke(null, input, region, found);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
        naive(input, region, expected);
        BoofTesting.assertEquals(found, expected, 1e-4);
    }
}
Also used : ImageGray(boofcv.struct.image.ImageGray) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 95 with ImageGray

use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.

the class TestConvolveImageStandard_SB method testMethod.

/**
 * Using the method's name and the number of parameters invoke the appropriate test function
 */
private void testMethod(Method m) {
    Class[] param = m.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(param[1], width, height);
    ImageGray output = GeneralizedImageOps.createSingleBand(param[2], width, height);
    GImageMiscOps.fillUniform(input, rand, 1, maxPixelValue);
    if (m.getName().contentEquals("horizontal")) {
        if (param.length == 3) {
            BoofTesting.checkSubImage(this, "horizontal", true, input, output);
        } else {
            BoofTesting.checkSubImage(this, "horizontalDiv", true, input, output);
        }
    } else if (m.getName().contentEquals("vertical")) {
        if (param.length == 3) {
            BoofTesting.checkSubImage(this, "vertical", true, input, output);
        } else {
            BoofTesting.checkSubImage(this, "verticalDiv", true, input, output);
        }
    } else if (m.getName().contentEquals("convolve")) {
        if (param.length == 3) {
            BoofTesting.checkSubImage(this, "convolve", true, input, output);
        } else {
            BoofTesting.checkSubImage(this, "convolveDiv", true, input, output);
        }
    } else {
        fail("Unknown method name: " + m.getName());
    }
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

Aggregations

ImageGray (boofcv.struct.image.ImageGray)110 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)43 GImageGray (boofcv.core.image.GImageGray)43 Test (org.junit.Test)26 GrayF32 (boofcv.struct.image.GrayF32)20 Method (java.lang.reflect.Method)17 GrayU8 (boofcv.struct.image.GrayU8)15 Bitmap (android.graphics.Bitmap)4 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)4 GrayS16 (boofcv.struct.image.GrayS16)4 GrayS32 (boofcv.struct.image.GrayS32)4 Planar (boofcv.struct.image.Planar)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)3 ImageRectangle (boofcv.struct.ImageRectangle)3 FDistort (boofcv.abst.distort.FDistort)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2