Search in sources :

Example 96 with ImageGray

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

the class GeneralChecksInterpolationPixelMB method compareToSingleBand.

/**
 * Compares interpolation to two single band images and sees if they produce nearly identical results
 */
@Test
public void compareToSingleBand() {
    T origMB = createImage(30, 40, 2);
    GImageMiscOps.fillUniform(origMB, rand, 0, 100);
    ImageDataType dataType = origMB.getImageType().getDataType();
    ImageGray band0 = GeneralizedImageOps.createSingleBand(dataType, origMB.width, origMB.height);
    ImageGray band1 = GeneralizedImageOps.createSingleBand(dataType, origMB.width, origMB.height);
    for (int y = 0; y < origMB.height; y++) {
        for (int x = 0; x < origMB.width; x++) {
            double val0 = GeneralizedImageOps.get(origMB, x, y, 0);
            double val1 = GeneralizedImageOps.get(origMB, x, y, 1);
            GeneralizedImageOps.set(band0, x, y, val0);
            GeneralizedImageOps.set(band1, x, y, val1);
        }
    }
    InterpolatePixelS interpBand0 = wrapSingle(band0, 0, 255);
    InterpolatePixelS interpBand1 = wrapSingle(band1, 0, 255);
    InterpolatePixelMB<T> interpMB = wrap(origMB, 0, 255);
    interpBand0.setBorder(FactoryImageBorder.genericValue(0, band0.getImageType()));
    interpBand1.setBorder(FactoryImageBorder.genericValue(0, band1.getImageType()));
    interpMB.setBorder(FactoryImageBorder.genericValue(0, interpMB.getImageType()));
    interpBand0.setImage(band0);
    interpBand1.setImage(band1);
    interpMB.setImage(origMB);
    float[] values = new float[2];
    for (int y = 0; y < origMB.height - 1; y++) {
        for (int x = 0; x < origMB.width - 1; x++) {
            float val0 = interpBand0.get(x + 0.2f, y + 0.3f);
            float val1 = interpBand1.get(x + 0.2f, y + 0.3f);
            interpMB.get(x + 0.2f, y + 0.3f, values);
            assertEquals(val0, values[0], 1e-4f);
            assertEquals(val1, values[1], 1e-4f);
        }
    }
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) ImageGray(boofcv.struct.image.ImageGray) ImageDataType(boofcv.struct.image.ImageDataType) Test(org.junit.Test)

Example 97 with ImageGray

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

the class TestGradientToEdgeFeatures method direction.

public void direction(Method m) {
    Class[] params = m.getParameterTypes();
    ImageGray derivX = GeneralizedImageOps.createSingleBand(params[0], width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(params[0], width, height);
    GImageMiscOps.fillUniform(derivX, rand, 0, 10);
    GImageMiscOps.fillUniform(derivY, rand, 0, 10);
    BoofTesting.checkSubImage(this, "direction", true, m, derivX, derivY, intensity);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Example 98 with ImageGray

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

the class TestImplEdgeNonMaxSuppressionCrude method inner.

public void inner(Method m) {
    Class derivType = m.getParameterTypes()[1];
    GrayF32 input = new GrayF32(width, height);
    GrayF32 output = new GrayF32(width, height);
    ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
    input.set(2, 2, 20);
    input.set(1, 1, 30);
    input.set(1, 3, 30);
    input.set(3, 1, 30);
    input.set(3, 3, 30);
    // should not be suppressed
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            // set the direction of the gradient
            GeneralizedImageOps.set(derivX, 2, 2, i * 2 - 1);
            GeneralizedImageOps.set(derivY, 2, 2, j * 2 - 1);
            // adjust intensity values so that they will not suppress, but any errors will cause an error
            int dx = i == 0 ? -1 : 1;
            int dy = j == 0 ? -1 : 1;
            GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 10);
            GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 10);
            BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, false);
            GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 30);
            GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 30);
        }
    }
    // should be suppressed
    input.set(1, 1, 10);
    input.set(1, 3, 10);
    input.set(3, 1, 10);
    input.set(3, 3, 10);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            // set the direction of the gradient
            GeneralizedImageOps.set(derivX, 2, 2, i);
            GeneralizedImageOps.set(derivY, 2, 2, j);
            // adjust intensity values so that they will suppress, but any errors will cause an error
            int dx = i == 0 ? -1 : 1;
            int dy = j == 0 ? -1 : 1;
            GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 30);
            GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 30);
            BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, true);
            GeneralizedImageOps.set(input, 2 - dx, 2 - dy, 10);
            GeneralizedImageOps.set(input, 2 + dx, 2 + dy, 10);
        }
    }
    // uniform case should be NOT suppressed
    GImageMiscOps.fill(input, 2);
    BoofTesting.checkSubImage(this, "inner", true, m, input, derivX, derivY, output, false);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageGray(boofcv.struct.image.ImageGray)

Example 99 with ImageGray

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

the class TestImplEdgeNonMaxSuppressionCrude method border.

public void border(Method m) {
    Class derivType = m.getParameterTypes()[1];
    GrayF32 input = new GrayF32(width, height);
    GrayF32 output = new GrayF32(width, height);
    ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
    BoofTesting.checkSubImage(this, "border", true, m, input, derivX, derivY, output);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageGray(boofcv.struct.image.ImageGray)

Example 100 with ImageGray

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

the class TestImplGradientToEdgeFeatures method intensityE.

public void intensityE(Method m) throws InvocationTargetException, IllegalAccessException {
    Class derivType = m.getParameterTypes()[0];
    ImageGray derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
    GImageMiscOps.fillUniform(derivX, rand, -20, 20);
    GImageMiscOps.fillUniform(derivY, rand, -20, 20);
    GrayF32 intensity = new GrayF32(width, height);
    BoofTesting.checkSubImage(this, "intensityE", false, m, derivX, derivY, intensity);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) 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