Search in sources :

Example 1 with Affine2D_F32

use of georegression.struct.affine.Affine2D_F32 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 Affine2D_F32

use of georegression.struct.affine.Affine2D_F32 in project BoofCV by lessthanoptimal.

the class TestDistortImageOps method boundBox_check.

/**
 * boundBox that checks to see if it is contained inside the output image.
 */
@Test
public void boundBox_check() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_I32 found = DistortImageOps.boundBox(10, 20, 30, 40, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(10, found.width);
    assertEquals(20, found.height);
    // bottom right border
    found = DistortImageOps.boundBox(10, 20, 8, 18, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(6, found.width);
    assertEquals(15, found.height);
    // top right border
    affine.set(new Affine2D_F32(1, 0, 0, 1, -2, -3));
    found = DistortImageOps.boundBox(10, 20, 8, 18, transform);
    assertEquals(0, found.x0);
    assertEquals(0, found.y0);
    assertEquals(8, found.width);
    assertEquals(17, found.height);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Test(org.junit.Test)

Example 3 with Affine2D_F32

use of georegression.struct.affine.Affine2D_F32 in project BoofCV by lessthanoptimal.

the class TestPixelTransformCached_F32 method compareToOrig.

@Test
public void compareToOrig() {
    PixelTransformAffine_F32 orig = new PixelTransformAffine_F32();
    orig.set(new Affine2D_F32(1f, 0.1f, 0.05f, 2f, 5f, 6f));
    PixelTransformCached_F32 alg = new PixelTransformCached_F32(width, height, orig);
    // it goes outside the border by one since some times the outside bound is used
    for (int y = 0; y < height + 1; y++) {
        for (int x = 0; x < width + 1; x++) {
            alg.compute(x, y);
            orig.compute(x, y);
            assertEquals(orig.distX, alg.distX, 1e-8);
            assertEquals(orig.distY, alg.distY, 1e-8);
        }
    }
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) Test(org.junit.Test)

Example 4 with Affine2D_F32

use of georegression.struct.affine.Affine2D_F32 in project BoofCV by lessthanoptimal.

the class TestLensDistortionOps method boundBoxInside_F32.

@Test
public void boundBoxInside_F32() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 1, 0, 1, 1, 2);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_F32 found = LensDistortionOps.boundBoxInside(20, 10, transform);
    assertEquals(10, found.x0, 1e-4);
    assertEquals(2, found.y0, 1e-4);
    assertEquals(20 - 9, found.width, 1e-4);
    assertEquals(10, found.height, 1e-4);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) Test(org.junit.Test)

Example 5 with Affine2D_F32

use of georegression.struct.affine.Affine2D_F32 in project BoofCV by lessthanoptimal.

the class TestImplPolynomialPixel_I method compareToBilinear.

/**
 * Polynomial interpolation of order one is bilinear interpolation
 */
@Test
public void compareToBilinear() {
    GrayU8 img = new GrayU8(width, height);
    GrayU8 expected = new GrayU8(width, height);
    GrayU8 found = new GrayU8(width, height);
    GImageMiscOps.fillUniform(img, rand, 0, 255);
    Affine2D_F32 tran = new Affine2D_F32(1, 0, 0, 1, 0.25f, 0.25f);
    // set it up so that it will be equivalent to bilinear interpolation
    InterpolatePixelS<GrayU8> alg = (InterpolatePixelS) new ImplPolynomialPixel_I(2, 0, 255);
    alg.setBorder(FactoryImageBorder.singleValue(GrayU8.class, 0));
    ImageDistort<GrayU8, GrayU8> distorter = FactoryDistort.distortSB(false, alg, GrayU8.class);
    distorter.setModel(new PixelTransformAffine_F32(tran));
    distorter.apply(img, found);
    InterpolatePixelS<GrayU8> bilinear = FactoryInterpolation.bilinearPixelS(GrayU8.class, BorderType.ZERO);
    distorter = FactoryDistort.distortSB(false, bilinear, GrayU8.class);
    distorter.setModel(new PixelTransformAffine_F32(tran));
    distorter.apply(img, expected);
    BoofTesting.assertEquals(expected, found, 0);
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) Affine2D_F32(georegression.struct.affine.Affine2D_F32) GrayU8(boofcv.struct.image.GrayU8) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Test(org.junit.Test)

Aggregations

Affine2D_F32 (georegression.struct.affine.Affine2D_F32)21 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)13 Test (org.junit.Test)11 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)6 GrayU8 (boofcv.struct.image.GrayU8)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)3 Affine2D_F64 (georegression.struct.affine.Affine2D_F64)2 Homography2D_F32 (georegression.struct.homography.Homography2D_F32)2 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)2 RectangleLength2D_F32 (georegression.struct.shapes.RectangleLength2D_F32)2 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)2 ArrayList (java.util.ArrayList)2 PixelTransformHomography_F32 (boofcv.alg.distort.PixelTransformHomography_F32)1 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)1 GrayF32 (boofcv.struct.image.GrayF32)1 ImageGray (boofcv.struct.image.ImageGray)1 Planar (boofcv.struct.image.Planar)1 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)1 Point2D_F32 (georegression.struct.point.Point2D_F32)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1