Search in sources :

Example 76 with GrayF32

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

the class TestPyramidFloatScale method update.

/**
 * Compares update to a convolution and sub-sampling of upper layers.
 */
@Test
public void update() {
    GrayF32 input = new GrayF32(width, height);
    BoofTesting.checkSubImage(this, "_update", true, input);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 77 with GrayF32

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

the class TestGPixelMath method all_planar_images.

/**
 * Tests all functions with inputs from planar images
 */
@Test
public void all_planar_images() {
    int total = 0;
    Method[] methods = GPixelMath.class.getMethods();
    for (Method m : methods) {
        if (!Modifier.isStatic(m.getModifiers()))
            continue;
        Class[] param = m.getParameterTypes();
        if (param.length < 1)
            continue;
        // create input arguments
        Object[] inputs = new Object[param.length];
        for (int i = 0; i < inputs.length; i++) {
            if (param[i] == ImageBase.class) {
                inputs[i] = new Planar(GrayF32.class, width, height, 2);
                GImageMiscOps.fillUniform((ImageBase) inputs[i], rand, -100, 100);
            }
        }
        // specialized inputs for individual functions
        String name = m.getName();
        if (name.equals("divide") && param.length == 3) {
            if (!ImageBase.class.isAssignableFrom(param[1])) {
                inputs[1] = 3;
            }
        } else if (name.equals("divide") && param.length == 5) {
            inputs[1] = 3;
            inputs[2] = -1;
            inputs[3] = 5;
        } else if (name.equals("multiply") && param.length == 3) {
            if (!ImageBase.class.isAssignableFrom(param[1])) {
                inputs[1] = 3;
            }
        } else if (name.equals("multiply") && param.length == 5) {
            inputs[1] = 3;
            inputs[2] = -20;
            inputs[3] = 12;
        } else if (name.equals("plus") && param.length == 3) {
            inputs[1] = 3;
        } else if (name.equals("plus") && param.length == 5) {
            inputs[1] = 3;
            inputs[2] = -10;
            inputs[3] = 12;
        } else if (name.equals("minus") && param.length == 3) {
            boolean first = ImageBase.class.isAssignableFrom(param[0]);
            inputs[first ? 1 : 0] = 3;
        } else if (name.equals("minus") && param.length == 5) {
            boolean first = ImageBase.class.isAssignableFrom(param[0]);
            inputs[first ? 1 : 0] = 3;
            inputs[2] = -10;
            inputs[3] = 12;
        } else if (name.equals("boundImage")) {
            inputs[1] = 2;
            inputs[2] = 8;
        } else if (name.equals("averageBand")) {
            continue;
        }
        try {
            // create the expected results
            Object[] inputsByBand = copy(inputs);
            invokeByBand(m, inputsByBand);
            // invoke this function
            m.invoke(null, inputs);
            // compare against each other
            for (int i = 0; i < inputs.length; i++) {
                if (Planar.class == inputs[i].getClass()) {
                    BoofTesting.assertEquals((ImageBase) inputs[i], (ImageBase) inputsByBand[i], 1e-4);
                }
            }
            total++;
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
    assertEquals(21, total);
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) ImageBase(boofcv.struct.image.ImageBase) Test(org.junit.Test)

Example 78 with GrayF32

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

the class GeneralBilinearRectangleChecks method region.

public void region(T img) {
    InterpolatePixelS<T> interpPt = createPixelInterpolate();
    InterpolateRectangle<T> interp = createRectangleInterpolate();
    interp.setImage(img);
    interpPt.setImage(img);
    GrayF32 out = new GrayF32(regionWidth, regionHeight);
    interp.region(tl_x, tl_y, out);
    for (int y = 0; y < regionHeight; y++) {
        for (int x = 0; x < regionWidth; x++) {
            assertEquals("( " + x + " , " + y + " )", interpPt.get(x + tl_x, y + tl_y), out.get(x, y), 1e-4);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 79 with GrayF32

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

the class GeneralBilinearRectangleChecks method outsideImageBorder1_barely.

@Test(expected = IllegalArgumentException.class)
public void outsideImageBorder1_barely() {
    T img = createImage(20, 25);
    InterpolateRectangle<T> interp = createRectangleInterpolate();
    interp.setImage(img);
    GrayF32 out = new GrayF32(20, 25);
    interp.region(-0.1f, -0.1f, out);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 80 with GrayF32

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

the class TestImplWaveletTransformNaive method testEncodeDecode_F32.

private void testEncodeDecode_F32(int widthOrig, int heightOrig, int widthOut, int heightOut) {
    GrayF32 orig = new GrayF32(widthOrig, heightOrig);
    ImageMiscOps.fillUniform(orig, rand, 0, 30);
    GrayF32 transformed = new GrayF32(widthOut, heightOut);
    GrayF32 reconstructed = new GrayF32(widthOrig, heightOrig);
    BoofTesting.checkSubImage(this, "checkTransforms_F32", true, orig, transformed, reconstructed);
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13