Search in sources :

Example 1 with Planar

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

the class DistortImageOps method affine.

/**
 * <p>
 * Applies an affine transformation from the input image to the output image.
 * </p>
 *
 * <p>
 * Input coordinates (x,y) to output coordinate (x',y')<br>
 * x' = a11*x + a12*y + dx<br>
 * y' = a21*x + a22*y + dy
 * </p>
 * @param input Which which is being rotated.
 * @param output The image in which the output is written to.
 * @param borderType Describes how pixels outside the image border should be handled.
 * @param interpType Which type of interpolation will be used.
 *
 * @deprecated As of v0.19.  Use {@link FDistort} instead
 */
@Deprecated
public static <T extends ImageBase<T>> void affine(T input, T output, BorderType borderType, InterpolationType interpType, double a11, double a12, double a21, double a22, double dx, double dy) {
    Affine2D_F32 m = new Affine2D_F32();
    m.a11 = (float) a11;
    m.a12 = (float) a12;
    m.a21 = (float) a21;
    m.a22 = (float) a22;
    m.tx = (float) dx;
    m.ty = (float) dy;
    m = m.invert(null);
    PixelTransformAffine_F32 model = new PixelTransformAffine_F32(m);
    if (input instanceof ImageGray) {
        distortSingle((ImageGray) input, (ImageGray) output, model, interpType, borderType);
    } else if (input instanceof Planar) {
        distortPL((Planar) input, (Planar) output, model, borderType, interpType);
    }
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) Planar(boofcv.struct.image.Planar) ImageGray(boofcv.struct.image.ImageGray)

Example 2 with Planar

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

the class DistortImageOps method rotate.

/**
 * <p>
 * Rotates the image using the specified interpolation type.  The rotation is performed
 * around the specified center of rotation in the input image.
 * </p>
 *
 * <p>
 * Input coordinates (x,y) to output coordinate (x',y')<br>
 * x' = x_c + c*(x-x_c) - s(y - y_c)<br>
 * y' = y_c + s*(x-x_c) + c(y - y_c)
 * </p>
 *
 * @deprecated As of v0.19.  Use {@link FDistort} instead
 *
 * @param input Which which is being rotated.
 * @param output The image in which the output is written to.
 * @param borderType Describes how pixels outside the image border should be handled.
 * @param interpType Which type of interpolation will be used.
 * @param angleInputToOutput Angle of rotation in radians. From input to output, CCW rotation.
 */
@Deprecated
public static <T extends ImageBase<T>> void rotate(T input, T output, BorderType borderType, InterpolationType interpType, float angleInputToOutput) {
    // (output.width+1)%2;
    float offX = 0;
    // (output.height+1)%2;
    float offY = 0;
    PixelTransform2_F32 model = DistortSupport.transformRotate(input.width / 2, input.height / 2, output.width / 2 - offX, output.height / 2 - offY, angleInputToOutput);
    if (input instanceof ImageGray) {
        distortSingle((ImageGray) input, (ImageGray) output, model, interpType, borderType);
    } else if (input instanceof Planar) {
        distortPL((Planar) input, (Planar) output, model, borderType, interpType);
    }
}
Also used : Planar(boofcv.struct.image.Planar) ImageGray(boofcv.struct.image.ImageGray) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32)

Example 3 with Planar

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

the class TestGradientMultiToSingleBand_Reflection method expected.

/**
 * Pass in a simple method and see if it is invoked correctly
 */
@Test
public void expected() {
    try {
        Method m = getClass().getMethod("helper", Planar.class, Planar.class, GrayF32.class, GrayF32.class);
        GradientMultiToSingleBand_Reflection alg = new GradientMultiToSingleBand_Reflection(m, ImageType.pl(3, GrayF32.class), GrayF32.class);
        assertTrue(alg.getInputType().getFamily() == ImageType.Family.PLANAR);
        assertTrue(alg.getOutputType() == GrayF32.class);
        Planar<GrayF32> inX = new Planar<>(GrayF32.class, 10, 12, 3);
        Planar<GrayF32> inY = new Planar<>(GrayF32.class, 10, 12, 3);
        GrayF32 outX = new GrayF32(10, 12);
        GrayF32 outY = new GrayF32(10, 12);
        alg.process(inX, inY, outX, outY);
        assertEquals(2, outX.data[5], 1e-4f);
        assertEquals(3, outY.data[5], 1e-4f);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 4 with Planar

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

the class TestInterpolatePixel_PL_using_SB method compareToIndividual.

@Test
public void compareToIndividual() {
    GrayF32 image0 = new GrayF32(width, height);
    GrayF32 image1 = new GrayF32(width, height);
    ImageMiscOps.fillUniform(image0, rand, 0, 100);
    ImageMiscOps.fillUniform(image1, rand, 0, 100);
    InterpolatePixelS<GrayF32> interpA = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED);
    InterpolatePixelS<GrayF32> interpB = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED);
    InterpolatePixelMB<Planar<GrayF32>> alg = new InterpolatePixel_PL_using_SB<>(interpB);
    Planar<GrayF32> mb = new Planar<>(GrayF32.class, width, height, 2);
    mb.bands[0] = image0;
    mb.bands[1] = image1;
    alg.setImage(mb);
    float[] vals = new float[2];
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            float xx = (rand.nextFloat() - 0.5f) + x;
            float yy = (rand.nextFloat() - 0.5f) + y;
            if (xx < 0)
                xx = 0;
            else if (xx > width - 1)
                xx = width - 1;
            if (yy < 0)
                yy = 0;
            else if (yy > height - 1)
                yy = height - 1;
            alg.get(xx, yy, vals);
            interpA.setImage(image0);
            float expected0 = interpA.get(xx, yy);
            interpA.setImage(image1);
            float expected1 = interpA.get(xx, yy);
            assertEquals(expected0, vals[0], 1e-4);
            assertEquals(expected1, vals[1], 1e-4);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 5 with Planar

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

the class TestDataManipulationOps method imageToTensor_fail.

@Test
public void imageToTensor_fail() {
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 30, 25, 2);
    try {
        DataManipulationOps.imageToTensor(image, new Tensor_F32(2, 25, 30), 0);
        fail("expected exception");
    } catch (RuntimeException ignore) {
    }
    try {
        DataManipulationOps.imageToTensor(image, new Tensor_F32(0, 3, 25, 30), 0);
        fail("expected exception");
    } catch (RuntimeException ignore) {
    }
    try {
        DataManipulationOps.imageToTensor(image, new Tensor_F32(1, 2, 26, 30), 0);
        fail("expected exception");
    } catch (RuntimeException ignore) {
    }
    try {
        DataManipulationOps.imageToTensor(image, new Tensor_F32(1, 2, 25, 31), 0);
        fail("expected exception");
    } catch (RuntimeException ignore) {
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Tensor_F32(deepboof.tensors.Tensor_F32) Test(org.junit.Test)

Aggregations

Planar (boofcv.struct.image.Planar)73 Test (org.junit.Test)39 GrayF32 (boofcv.struct.image.GrayF32)34 GrayU8 (boofcv.struct.image.GrayU8)28 BufferedImage (java.awt.image.BufferedImage)21 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)20 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)12 File (java.io.File)9 Bitmap (android.graphics.Bitmap)4 ListDisplayPanel (boofcv.gui.ListDisplayPanel)4 ImageGray (boofcv.struct.image.ImageGray)4 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)3 LensDistortionUniversalOmni (boofcv.alg.distort.universal.LensDistortionUniversalOmni)3 MediaManager (boofcv.io.MediaManager)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU16 (boofcv.struct.image.GrayU16)3 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Se3_F64 (georegression.struct.se.Se3_F64)3 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)2