Search in sources :

Example 6 with ImageGray

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

the class TestThresholdImageOps method localGaussian.

@Test
public void localGaussian() {
    int total = 0;
    Method[] list = ThresholdImageOps.class.getMethods();
    for (Method m : list) {
        if (!m.getName().equals("localGaussian"))
            continue;
        Class[] param = m.getParameterTypes();
        ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
        GrayU8 output = new GrayU8(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 200);
        BoofTesting.checkSubImage(this, "performLocalGaussian", true, m, input, output);
        total++;
    }
    assertEquals(2, total);
}
Also used : 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 7 with ImageGray

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

the class TestThresholdImageOps method naiveLocalSquare.

public void naiveLocalSquare(ImageGray input, GrayU8 output, int radius, double scale, boolean down) {
    ImageGray blur;
    boolean isInt;
    if (input instanceof GrayU8) {
        isInt = true;
        blur = BlurImageOps.mean((GrayU8) input, null, radius, null);
    } else {
        isInt = false;
        blur = BlurImageOps.mean((GrayF32) input, null, radius, null);
    }
    float fscale = (float) scale;
    for (int y = 0; y < input.height; y++) {
        for (int x = 0; x < input.width; x++) {
            double threshold = GeneralizedImageOps.get(blur, x, y);
            double v = GeneralizedImageOps.get(input, x, y);
            boolean one;
            if (down) {
                if (isInt) {
                    one = (int) v <= ((int) threshold) * fscale;
                } else {
                    one = v <= threshold * fscale;
                }
            } else {
                if (isInt) {
                    one = ((int) v) * fscale > (int) threshold;
                } else {
                    one = v * fscale > threshold;
                }
            }
            if (one) {
                output.set(x, y, 1);
            } else {
                output.set(x, y, 0);
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8)

Example 8 with ImageGray

use of boofcv.struct.image.ImageGray 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 9 with ImageGray

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

the class TestImplMedianSortEdgeNaive method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class[] c = candidate.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(c[0], width, height);
    ImageGray output = GeneralizedImageOps.createSingleBand(c[1], width, height);
    Object[][] ret = new Object[1][c.length];
    ret[0][0] = input;
    ret[0][1] = output;
    ret[0][2] = radius;
    ret[0][3] = null;
    return ret;
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 10 with ImageGray

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

the class TestImplMedianSortNaive method trivialTest.

@Test
public void trivialTest() {
    GrayU8 templateImage = new GrayU8(4, 4);
    for (int i = 0; i < templateImage.width; i++) {
        for (int j = 0; j < templateImage.height; j++) {
            templateImage.set(j, i, i * templateImage.width + j);
        }
    }
    int numFound = 0;
    Method[] methods = ImplMedianSortNaive.class.getMethods();
    for (Method m : methods) {
        if (!m.getName().equals("process"))
            continue;
        if (m.getParameterTypes().length != 4)
            continue;
        Class[] params = m.getParameterTypes();
        ImageGray input = GeneralizedImageOps.createSingleBand(params[0], 4, 4);
        ImageGray found = GeneralizedImageOps.createSingleBand(params[1], 4, 4);
        GConvertImage.convert(templateImage, input);
        BoofTesting.checkSubImage(this, "trivialTest", true, m, input, found);
        numFound++;
    }
    assertEquals(2, numFound);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray) Method(java.lang.reflect.Method) Test(org.junit.Test)

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