Search in sources :

Example 51 with GrayF32

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

the class IntensityFeaturePyramidApp method main.

public static void main(String[] args) {
    IntensityFeaturePyramidApp<GrayF32, GrayF32> app = new IntensityFeaturePyramidApp<>(GrayF32.class, GrayF32.class);
    // IntensityFeaturePyramidApp<GrayU8, GrayS16> app =
    // new IntensityFeaturePyramidApp<GrayU8,GrayS16>(GrayU8.class,GrayS16.class);
    java.util.List<PathLabel> inputs = new ArrayList<>();
    inputs.add(new PathLabel("shapes", UtilIO.pathExample("shapes/shapes01.png")));
    inputs.add(new PathLabel("amoeba", UtilIO.pathExample("amoeba_shapes.jpg")));
    inputs.add(new PathLabel("sunflowers", UtilIO.pathExample("sunflowers.jpg")));
    inputs.add(new PathLabel("beach", UtilIO.pathExample("scale/beach02.jpg")));
    app.setInputList(inputs);
    // wait for it to process one image so that the size isn't all screwed up
    while (!app.getHasProcessedImage()) {
        Thread.yield();
    }
    ShowImages.showWindow(app, "Feature Scale Space Pyramid Intensity", true);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PathLabel(boofcv.io.PathLabel) ArrayList(java.util.ArrayList)

Example 52 with GrayF32

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

the class IntensityFeaturePyramidApp method process.

public void process(final BufferedImage input) {
    setInputImage(input);
    this.input = input;
    workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType);
    scaledIntensity = new GrayF32(workImage.width, workImage.height);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            setPreferredSize(new Dimension(input.getWidth(), input.getHeight()));
            processedImage = true;
        }
    });
    doRefreshAll();
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 53 with GrayF32

use of boofcv.struct.image.GrayF32 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)

Example 54 with GrayF32

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

the class DebugSiftDetectorApp method main.

public static void main(String[] args) {
    BufferedImage input = UtilImageIO.loadImage(UtilIO.pathExample("sunflowers.jpg"));
    // BufferedImage input = UtilImageIO.loadImage(UtilIO.pathExample("shapes/shapes01.png");
    GrayF32 gray = ConvertBufferedImage.convertFromSingle(input, null, GrayF32.class);
    NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(3, 1, 1, true, true, true));
    NonMaxLimiter extractor = new NonMaxLimiter(nonmax, 400);
    SiftScaleSpace imageSS = new SiftScaleSpace(-1, 5, 3, 2.75);
    SiftDetector alg = new SiftDetector(imageSS, 10, extractor);
    alg.process(gray);
    System.out.println("total features found: " + alg.getDetections().size());
    VisualizeFeatures.drawScalePoints(input.createGraphics(), alg.getDetections().toList(), 1);
    // ListDisplayPanel dog = new ListDisplayPanel();
    // for( int i = 0; i < alg.getScaleSpace().getDog().length; i++ ) {
    // int scale = i % (alg.getScaleSpace().getNumScales()-1);
    // int octave = i / (alg.getScaleSpace().getNumScales()-1);
    // 
    // BufferedImage img = VisualizeImageData.colorizeSign(alg.getScaleSpace().getDog()[i],null,-1);
    // dog.addImage(img,octave+"  "+scale);
    // }
    // 
    // ListDisplayPanel ss = new ListDisplayPanel();
    // for( int i = 0; i < alg.getScaleSpace().getScale().length; i++ ) {
    // int scale = i % alg.getScaleSpace().getNumScales();
    // int octave = i / alg.getScaleSpace().getNumScales();
    // 
    // BufferedImage img = VisualizeImageData.grayMagnitude(alg.getScaleSpace().getScale()[i],null,255);
    // ss.addImage(img,octave+"  "+scale);
    // }
    // ShowImages.showWindow(dog, "Octave DOG");
    // ShowImages.showWindow(ss, "Octave Scales");
    ShowImages.showWindow(input, "Found Features", true);
    System.out.println("Done");
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxLimiter(boofcv.abst.feature.detect.extract.NonMaxLimiter) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) GrayF32(boofcv.struct.image.GrayF32) SiftScaleSpace(boofcv.alg.feature.detect.interest.SiftScaleSpace) SiftDetector(boofcv.alg.feature.detect.interest.SiftDetector) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 55 with GrayF32

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

the class VisualizeSquareBinaryFiducial method process.

public void process(String nameImage, String nameIntrinsic) {
    CameraPinholeRadial intrinsic = nameIntrinsic == null ? null : (CameraPinholeRadial) CalibrationIO.load(nameIntrinsic);
    GrayF32 input = UtilImageIO.loadImage(nameImage, GrayF32.class);
    GrayF32 undistorted = new GrayF32(input.width, input.height);
    InputToBinary<GrayF32> inputToBinary = FactoryThresholdBinary.globalOtsu(0, 255, true, GrayF32.class);
    Detector detector = new Detector(gridWidth, borderWidth, inputToBinary);
    detector.setLengthSide(0.1);
    if (intrinsic != null) {
        CameraPinholeRadial paramUndist = new CameraPinholeRadial();
        ImageDistort<GrayF32, GrayF32> undistorter = LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND, BorderType.EXTENDED, intrinsic, new CameraPinhole(intrinsic), paramUndist, ImageType.single(GrayF32.class));
        detector.configure(new LensDistortionRadialTangential(paramUndist), paramUndist.width, paramUndist.height, false);
        undistorter.apply(input, undistorted);
        detector.process(undistorted);
    } else {
        detector.process(input);
    }
    System.out.println("Total Found: " + detector.squares.size());
    FastQueue<FoundFiducial> fiducials = detector.getFound();
    int N = Math.min(20, detector.squares.size());
    ListDisplayPanel squares = new ListDisplayPanel();
    for (int i = 0; i < N; i++) {
        squares.addImage(VisualizeBinaryData.renderBinary(detector.squares.get(i), false, null), " " + i);
        squares.addImage(ConvertBufferedImage.convertTo(detector.squaresGray.get(i), null), " " + i);
    }
    BufferedImage output = new BufferedImage(input.width, input.height, BufferedImage.TYPE_INT_RGB);
    ConvertBufferedImage.convertTo(input, output);
    Graphics2D g2 = output.createGraphics();
    g2.setColor(Color.RED);
    g2.setStroke(new BasicStroke(2));
    for (int i = 0; i < N; i++) {
        VisualizeShapes.drawArrowSubPixel(fiducials.get(i).distortedPixels, 3, 1, g2);
    }
    ShowImages.showWindow(output, "Binary", true);
    ShowImages.showWindow(squares, "Candidates", true);
}
Also used : ListDisplayPanel(boofcv.gui.ListDisplayPanel) FoundFiducial(boofcv.alg.fiducial.square.FoundFiducial) CameraPinhole(boofcv.struct.calib.CameraPinhole) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) GrayF32(boofcv.struct.image.GrayF32) FactoryShapeDetector(boofcv.factory.shape.FactoryShapeDetector) ConfigPolygonDetector(boofcv.factory.shape.ConfigPolygonDetector) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13