Search in sources :

Example 21 with ImageGray

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

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

the class GenericWaveletDenoiseTests method denoiseImage.

@Override
public void denoiseImage(T imageNoisy, T imageDenoised) {
    ImageGray transformedImg = transform.transform(imageNoisy, null);
    // so this condition is also tested
    if (imageNoisy.isSubimage()) {
        transformedImg = (T) BoofTesting.createSubImageOf(transformedImg);
    }
    denoiseWavelet(transformedImg, transform.getLevels());
    transform.invert(transformedImg, imageDenoised);
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

Example 23 with ImageGray

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

the class TestImageMiscOps method testCopy.

private void testCopy(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray src = GeneralizedImageOps.createSingleBand(paramTypes[6], width, height);
    ImageGray dst = GeneralizedImageOps.createSingleBand(paramTypes[7], width, height);
    GImageMiscOps.fillUniform(src, rand, 0, 20);
    GImageMiscOps.fillUniform(dst, rand, 0, 20);
    int w = 5, h = 8;
    int x0 = 1, y0 = 2;
    int x1 = 3, y1 = 4;
    m.invoke(null, 1, 2, 3, 4, w, h, src, dst);
    GImageGray a = FactoryGImageGray.wrap(src);
    GImageGray b = FactoryGImageGray.wrap(dst);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            assertEquals(a.get(x0 + j, y0 + i).doubleValue(), b.get(x1 + j, y1 + i).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 24 with ImageGray

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

the class TestImageMiscOps method testFlipVertical.

private void testFlipVertical(Method m, int height) throws IllegalAccessException, InvocationTargetException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray imgA = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    GImageMiscOps.fillUniform(imgA, rand, 0, 100);
    ImageGray imgB = (ImageGray) imgA.clone();
    m.invoke(null, imgB);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            double valA = GeneralizedImageOps.get(imgA, x, height - y - 1);
            double valB = GeneralizedImageOps.get(imgB, x, y);
            assertTrue(valA == valB);
        }
    }
}
Also used : FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GImageGray(boofcv.core.image.GImageGray)

Example 25 with ImageGray

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

the class TestImageMiscOps method testFillRectangle_Single.

private void testFillRectangle_Single(Method m) throws InvocationTargetException, IllegalAccessException {
    Class[] paramTypes = m.getParameterTypes();
    ImageGray orig = GeneralizedImageOps.createSingleBand(paramTypes[0], width, height);
    int x0 = 2;
    int y0 = 3;
    int width = 5;
    int height = 6;
    if (orig.getDataType().isInteger()) {
        m.invoke(null, orig, 10, x0, y0, width, height);
    } else {
        m.invoke(null, orig, 10.0f, x0, y0, width, height);
    }
    GImageGray a = FactoryGImageGray.wrap(orig);
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            if (j < x0 || i < y0 || i >= (x0 + width) || j >= (y0 + height))
                assertEquals(j + " " + i, 0.0, a.get(j, i).doubleValue(), 1e-4);
            else
                assertEquals(10.0, a.get(j, i).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)

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