Search in sources :

Example 1 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestThresholdImageOps method threshold.

@Test
public void threshold() {
    int total = 0;
    Method[] list = ThresholdImageOps.class.getMethods();
    for (Method m : list) {
        if (!m.getName().equals("threshold"))
            continue;
        Class[] param = m.getParameterTypes();
        ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
        GrayU8 output = new GrayU8(width, height);
        GImageGray a = FactoryGImageGray.wrap(input);
        for (int y = 0; y < input.height; y++) {
            for (int x = 0; x < input.width; x++) {
                a.set(x, y, x);
            }
        }
        BoofTesting.checkSubImage(this, "performThreshold", true, m, input, output);
        total++;
    }
    assertEquals(6, total);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImplMedianSortEdgeNaive method compareResults.

@Override
protected void compareResults(Object targetResult, Object[] targetParam, Object validationResult, Object[] validationParam) {
    GImageGray found = FactoryGImageGray.wrap((ImageGray) targetParam[1]);
    GImageGray expected = FactoryGImageGray.wrap((ImageGray) validationParam[1]);
    for (int y = 0; y < height; y++) {
        if (y > radius || y < height - radius)
            continue;
        for (int x = 0; x < width; x++) {
            if (x > radius || x < width - radius)
                continue;
            assertEquals(found.get(x, y).intValue(), expected.get(x, y).intValue());
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 3 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImplGrayImageOps method stretch.

public void stretch(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] param = m.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
    ImageGray output = GeneralizedImageOps.createSingleBand(param[0], width, height);
    GImageMiscOps.fill(input, 23);
    m.invoke(null, input, 2.5, 10, 255, output);
    GImageGray b = FactoryGImageGray.wrap(output);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (output.getDataType().isInteger())
                assertEquals(67, b.get(x, y).doubleValue(), 1e-4);
            else
                assertEquals(67.5, b.get(x, y).doubleValue(), 1e-4);
        }
    }
    // check to see how well it sets the ceiling
    m.invoke(null, input, 10, 28, 255, output);
    assertEquals(255, b.get(5, 6).doubleValue(), 1e-4);
    // check it flooring to zero
    m.invoke(null, input, -1, 2, 255, output);
    assertEquals(0, b.get(5, 6).doubleValue(), 1e-4);
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 4 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestImplGrayImageOps method invert.

public void invert(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] param = m.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 100);
    ImageGray output = GeneralizedImageOps.createSingleBand(param[0], width, height);
    m.invoke(null, input, 255, output);
    GImageGray a = FactoryGImageGray.wrap(input);
    GImageGray b = FactoryGImageGray.wrap(output);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            assertEquals(255 - a.get(x, y).doubleValue(), b.get(x, y).doubleValue(), 1e-4f);
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 5 with GImageGray

use of boofcv.core.image.GImageGray in project BoofCV by lessthanoptimal.

the class TestShrinkThresholdSoft_I32 method performBasicSoftTest.

public static <T extends ImageGray<T>> void performBasicSoftTest(T image, ShrinkThresholdRule<T> rule) {
    final int height = image.height;
    final int width = image.width;
    GImageGray a = FactoryGImageGray.wrap(image);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            a.set(x, y, x);
        }
    }
    rule.process(image, 4);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (x < 4) {
                assertEquals(0, a.get(x, y).floatValue(), 1e-4);
            } else {
                assertEquals(x - 4, a.get(x, y).floatValue(), 1e-4);
            }
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray)

Aggregations

FactoryGImageGray (boofcv.core.image.FactoryGImageGray)35 GImageGray (boofcv.core.image.GImageGray)35 ImageGray (boofcv.struct.image.ImageGray)17 Test (org.junit.Test)5 Bitmap (android.graphics.Bitmap)3 TupleDesc_B (boofcv.struct.feature.TupleDesc_B)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)1 ImageRectangle (boofcv.struct.ImageRectangle)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1