Search in sources :

Example 16 with FDistort

use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.

the class ColorTrackerObjectRectangleTests method render.

@Override
protected void render(double scale, double tranX, double tranY) {
    // each region in the target region will have a different color.  Allowing scale, translation, and rotation
    // to be estimated using color information alone
    Quadrilateral_F64 q = initRegion.copy();
    // scale it down a bit so that there is a border
    if (multiColor)
        scale(q, 0.95);
    Point2D_F64 ab = average(q.a, q.b);
    Point2D_F64 bc = average(q.b, q.c);
    Point2D_F64 cd = average(q.c, q.d);
    Point2D_F64 da = average(q.d, q.a);
    Point2D_F64 abcd = average(ab, cd);
    Quadrilateral_F64 r0 = new Quadrilateral_F64(q.a, ab, abcd, da, true);
    Quadrilateral_F64 r1 = new Quadrilateral_F64(ab, q.b, bc, abcd, true);
    Quadrilateral_F64 r2 = new Quadrilateral_F64(abcd, bc, q.c, cd, true);
    Quadrilateral_F64 r3 = new Quadrilateral_F64(da, abcd, cd, q.d, true);
    Polygon2D_I32[] region = new Polygon2D_I32[4];
    region[0] = setPolygon(r0);
    region[1] = setPolygon(r1);
    region[2] = setPolygon(r2);
    region[3] = setPolygon(r3);
    int[] band0 = new int[] { 100, 50, 176, 0 };
    int[] band1 = new int[] { 150, 200, 240, 40 };
    int[] band2 = new int[] { 20, 234, 176, 210 };
    GImageMiscOps.fill(original, 0);
    GImageMiscOps.fill(input, 0);
    for (int i = 0; i < 4; i++) {
        int colorIndex;
        if (multiColor)
            colorIndex = i;
        else
            colorIndex = 0;
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(0), band0[colorIndex]);
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(1), band1[colorIndex]);
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(2), band2[colorIndex]);
    }
    new FDistort(original, input).affine(scale, 0, 0, scale, tranX, tranY).apply();
}
Also used : FDistort(boofcv.abst.distort.FDistort) Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32) Quadrilateral_F64(georegression.struct.shapes.Quadrilateral_F64)

Example 17 with FDistort

use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.

the class DisplayGaussianKernelApp method setActiveAlgorithm.

@Override
public void setActiveAlgorithm(String name, Object cookie) {
    DerivType type = (DerivType) cookie;
    panel.reset();
    for (int radius = 1; radius <= 40; radius += 2) {
        int maxOrder = Math.max(type.orderX, type.orderY);
        double sigma = FactoryKernelGaussian.sigmaForRadius(radius, maxOrder);
        Class typeKer1 = FactoryKernel.getKernelType(imageType, 1);
        Kernel1D kerX = FactoryKernelGaussian.derivativeK(typeKer1, type.orderX, sigma, radius);
        Kernel1D kerY = FactoryKernelGaussian.derivativeK(typeKer1, type.orderY, sigma, radius);
        Kernel2D kernel = GKernelMath.convolve(kerY, kerX);
        T smallImg = GKernelMath.convertToImage(kernel);
        new FDistort(smallImg, largeImg).interpNN().scaleExt().apply();
        double maxValue = GImageStatistics.maxAbs(largeImg);
        BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
        panel.addImage(out, String.format("%5d", radius));
    }
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D) FDistort(boofcv.abst.distort.FDistort) Kernel2D(boofcv.struct.convolve.Kernel2D) BufferedImage(java.awt.image.BufferedImage)

Example 18 with FDistort

use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.

the class DisplaySteerableBase method setActiveAlgorithm.

@Override
public void setActiveAlgorithm(String name, Object cookie) {
    DisplayGaussianKernelApp.DerivType dt = (DisplayGaussianKernelApp.DerivType) cookie;
    // add basis
    SteerableKernel<K> steerable = createKernel(dt.orderX, dt.orderY);
    basisPanel.reset();
    for (int i = 0; i < steerable.getBasisSize(); i++) {
        T smallImg = GKernelMath.convertToImage(steerable.getBasis(i));
        new FDistort(smallImg, largeImg).scaleExt().interpNN().apply();
        double maxValue = GImageStatistics.maxAbs(largeImg);
        BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
        basisPanel.addImage(out, "Basis " + i);
    }
    // add steered kernels
    steerPanel.reset();
    for (int i = 0; i <= 20; i++) {
        double angle = Math.PI * i / 20.0;
        K kernel = steerable.compute(angle);
        T smallImg = GKernelMath.convertToImage(kernel);
        new FDistort(smallImg, largeImg).scaleExt().interpNN().apply();
        double maxValue = GImageStatistics.maxAbs(largeImg);
        BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
        steerPanel.addImage(out, String.format("%5d", (int) (180.0 * angle / Math.PI)));
    }
    repaint();
}
Also used : FDistort(boofcv.abst.distort.FDistort) BufferedImage(java.awt.image.BufferedImage)

Example 19 with FDistort

use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.

the class DemonstrationInterpolateScaleApp method applyScaling.

private void applyScaling() {
    scaledImage.reshape(panel.getWidth(), panel.getHeight());
    if (scaledImage.width <= 0 || scaledImage.height <= 0) {
        return;
    }
    if (latestImage.width != 0 && latestImage.height != 0) {
        new FDistort(latestImage, scaledImage).interp(interpType).border(BorderType.EXTENDED).scale().apply();
        BufferedImage out = ConvertBufferedImage.convertTo(scaledImage, null, true);
        panel.setImageUI(out);
        panel.repaint();
    }
}
Also used : FDistort(boofcv.abst.distort.FDistort) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 20 with FDistort

use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.

the class SubpixelGridTargetDisplay method render.

private synchronized void render(Rectangle visibleRect) {
    if (visibleRect.width == 0 || visibleRect.height == 0)
        return;
    if (transformed.width != visibleRect.width || transformed.height != visibleRect.height || workImage == null) {
        transformed.reshape(visibleRect.width, visibleRect.height);
        workImage = new BufferedImage(visibleRect.width, visibleRect.height, BufferedImage.TYPE_INT_RGB);
    }
    double x = -visibleRect.x;
    double y = -visibleRect.y;
    new FDistort(input, transformed).interpNN().affine(scale, 0, 0, scale, x, y).apply();
    ConvertBufferedImage.convertTo(transformed, workImage, true);
}
Also used : FDistort(boofcv.abst.distort.FDistort) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Aggregations

FDistort (boofcv.abst.distort.FDistort)23 BufferedImage (java.awt.image.BufferedImage)11 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)9 GrayF32 (boofcv.struct.image.GrayF32)8 GrayU8 (boofcv.struct.image.GrayU8)3 Kernel1D (boofcv.struct.convolve.Kernel1D)2 Kernel2D (boofcv.struct.convolve.Kernel2D)2 ImageGray (boofcv.struct.image.ImageGray)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 File (java.io.File)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)1 SteerableKernel (boofcv.alg.filter.kernel.SteerableKernel)1 SteerableKernel_F32 (boofcv.alg.filter.kernel.impl.SteerableKernel_F32)1 SteerableKernel_I32 (boofcv.alg.filter.kernel.impl.SteerableKernel_I32)1 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)1 ListDisplayPanel (boofcv.gui.ListDisplayPanel)1 PanelGridPanel (boofcv.gui.PanelGridPanel)1 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)1 AnimatePanel (boofcv.gui.image.AnimatePanel)1