Search in sources :

Example 1 with FDistort

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

the class ScaleSpacePyramidPointPanel method setLevel.

private synchronized void setLevel(int level) {
    // System.out.println("level "+level);
    if (level > 0 && ss != null) {
        ImageGray small = (ImageGray) ss.getLayer(level - 1);
        ImageGray enlarge = GeneralizedImageOps.createSingleBand(small.getClass(), ss.getInputWidth(), ss.getInputHeight());
        new FDistort(small, enlarge).interpNN().apply();
        // if the size isn't the same null it so a new image will be declared
        if (levelImage != null && (levelImage.getWidth() != enlarge.width || levelImage.getHeight() != enlarge.height)) {
            levelImage = null;
        }
        levelImage = ConvertBufferedImage.convertTo(enlarge, levelImage, true);
        double scale = ss.getScale(level - 1);
        levelPoints.clear();
        for (ScalePoint p : points) {
            if (p.scale == scale) {
                levelPoints.add(p);
            }
        }
    } else {
        levelPoints.clear();
        levelPoints.addAll(points);
    }
    this.activeLevel = level;
}
Also used : FDistort(boofcv.abst.distort.FDistort) ScalePoint(boofcv.struct.feature.ScalePoint) ImageGray(boofcv.struct.image.ImageGray)

Example 2 with FDistort

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

the class ImagePyramidPanel method scaleUpLayers.

private void scaleUpLayers() {
    T l = pyramid.getLayer(0);
    if (upscale == null) {
        interp = (InterpolatePixelS<T>) FactoryInterpolation.nearestNeighborPixelS(l.getClass());
        upscale = (T) l.createNew(l.width, l.height);
    } else {
        upscale.reshape(l.width, l.height);
    }
    int N = pyramid.getNumLayers();
    for (int i = 0; i < N; i++) {
        new FDistort(pyramid.getLayer(i), upscale).interpNN().scaleExt().apply();
        BufferedImage b = ConvertBufferedImage.convertTo(upscale, null, true);
        if (showScales)
            addImage(b, String.format("%5.2f", pyramid.getScale(i)));
        else
            addImage(b, String.format("%5.2f", pyramid.getSigma(i)));
    }
}
Also used : FDistort(boofcv.abst.distort.FDistort) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 3 with FDistort

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

the class TestRemovePerspectiveDistortion method applyForwardTransform.

private void applyForwardTransform(GrayF32 expected, GrayF32 input, Point2D_F64 topLeft, Point2D_F64 topRight, Point2D_F64 bottomRight, Point2D_F64 bottomLeft) {
    Estimate1ofEpipolar computeHomography = FactoryMultiView.computeHomographyDLT(true);
    ArrayList<AssociatedPair> associatedPairs = new ArrayList<>();
    associatedPairs.add(new AssociatedPair(topLeft, new Point2D_F64(0, 0)));
    associatedPairs.add(new AssociatedPair(topRight, new Point2D_F64(expected.width - 1, 0)));
    associatedPairs.add(new AssociatedPair(bottomRight, new Point2D_F64(expected.width - 1, expected.height - 1)));
    associatedPairs.add(new AssociatedPair(bottomLeft, new Point2D_F64(0, expected.height - 1)));
    DMatrixRMaj H = new DMatrixRMaj(3, 3);
    computeHomography.process(associatedPairs, H);
    FMatrixRMaj H32 = new FMatrixRMaj(3, 3);
    ConvertMatrixData.convert(H, H32);
    new FDistort(expected, input).transform(new PointTransformHomography_F32(H32)).apply();
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) FMatrixRMaj(org.ejml.data.FMatrixRMaj) FDistort(boofcv.abst.distort.FDistort) Estimate1ofEpipolar(boofcv.abst.geo.Estimate1ofEpipolar) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 4 with FDistort

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

the class DenseFlowApp method changeInput.

@Override
public synchronized void changeInput(String name, int index) {
    BufferedImage image0 = media.openImage(inputRefs.get(index).getPath(0));
    BufferedImage image1 = media.openImage(inputRefs.get(index).getPath(1));
    // process at 1/2 resolution to make it faster
    unscaled.reshape(image0.getWidth(), image1.getHeight());
    input0.reshape(unscaled.width / 2, unscaled.height / 2);
    input1.reshape(unscaled.width / 2, unscaled.height / 2);
    flow.reshape(unscaled.width / 2, unscaled.height / 2);
    ConvertBufferedImage.convertFrom(image0, unscaled, false);
    new FDistort(unscaled, input0).scaleExt().apply();
    ConvertBufferedImage.convertFrom(image1, unscaled, false);
    new FDistort(unscaled, input1).scaleExt().apply();
    converted0 = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
    converted1 = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
    visualized = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
    ConvertBufferedImage.convertTo(input0, converted0, true);
    ConvertBufferedImage.convertTo(input1, converted1, true);
    hasInputImage = true;
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            flowPanel.setPreferredSize(new Dimension(input0.width, input0.height));
            flowPanel.setImage(visualized);
            animationPanel.setPreferredSize(new Dimension(input0.width, input0.height));
            animationPanel.setAnimation(converted0, converted1);
            gui.revalidate();
        }
    });
    doRefreshAll();
}
Also used : FDistort(boofcv.abst.distort.FDistort) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 5 with FDistort

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

the class IntensityFeaturePyramidApp method setActiveAlgorithm.

@Override
public void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
    if (input == null) {
        return;
    }
    if (indexFamily == 0) {
        intensity = (GeneralFeatureIntensity<T, D>) cookie;
        if (pyramid == null)
            return;
    } else if (indexFamily == 1) {
        // setup the pyramid
        double[] scales = new double[25];
        for (int i = 0; i < scales.length; i++) {
            scales[i] = Math.exp(i * 0.15);
        }
        if (((Number) cookie).intValue() == 0) {
            pyramid = FactoryPyramid.scaleSpacePyramid(scales, imageType);
        } else {
            pyramid = FactoryPyramid.scaleSpace(scales, imageType);
        }
        if (workImage != null)
            pyramid.process(workImage);
        if (intensity == null)
            return;
    }
    // setup the feature intensity
    gui.reset();
    BufferedImage b = VisualizeImageData.grayMagnitude(workImage, null, 255);
    gui.addImage(b, "Gray Image");
    final ProgressMonitor progressMonitor = new ProgressMonitor(this, "Computing Scale Space Pyramid Response", "", 0, pyramid.getNumLayers());
    for (int i = 0; i < pyramid.getNumLayers() && !progressMonitor.isCanceled(); i++) {
        double scale = pyramid.getSigma(i);
        T scaledImage = pyramid.getLayer(i);
        anyDerivative.setInput(scaledImage);
        D derivX = anyDerivative.getDerivative(true);
        D derivY = anyDerivative.getDerivative(false);
        D derivXX = anyDerivative.getDerivative(true, true);
        D derivYY = anyDerivative.getDerivative(false, false);
        D derivXY = anyDerivative.getDerivative(true, false);
        intensity.process(scaledImage, derivX, derivY, derivXX, derivYY, derivXY);
        GrayF32 featureImg = intensity.getIntensity();
        // scale it up to full resolution
        new FDistort(featureImg, scaledIntensity).interpNN().scaleExt().apply();
        // visualize the rescaled intensity
        b = VisualizeImageData.colorizeSign(scaledIntensity, null, ImageStatistics.maxAbs(scaledIntensity));
        gui.addImage(b, String.format("Scale %6.2f", scale));
        final int progressStatus = i + 1;
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                progressMonitor.setProgress(progressStatus);
            }
        });
    }
    gui.requestFocusInWindow();
}
Also used : GrayF32(boofcv.struct.image.GrayF32) 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