Search in sources :

Example 6 with ConfigThreshold

use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.

the class ShapeFitContourApp method imageThresholdUpdated.

@Override
public void imageThresholdUpdated() {
    ConfigThreshold config = controlPanel.getThreshold().createConfig();
    inputToBinary = FactoryThresholdBinary.threshold(config, GrayU8.class);
    reprocessImageOnly();
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) GrayU8(boofcv.struct.image.GrayU8)

Example 7 with ConfigThreshold

use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.

the class FiducialDetection method parseBinary.

void parseBinary(int index, String[] args) {
    boolean robust = true;
    double size = 1;
    int gridWidth = 4;
    double borderWidth = 0.25;
    for (; index < args.length; index++) {
        String arg = args[index];
        if (!arg.startsWith("--")) {
            throw new RuntimeException("Expected flags for binary fiducial");
        }
        splitFlag(arg);
        if (flagName.compareToIgnoreCase("Robust") == 0) {
            robust = Boolean.parseBoolean(parameters);
        } else if (flagName.compareToIgnoreCase("Size") == 0) {
            size = Double.parseDouble(parameters);
        } else if (flagName.compareToIgnoreCase("GridWidth") == 0) {
            gridWidth = Integer.parseInt(parameters);
        } else if (flagName.compareToIgnoreCase("Border") == 0) {
            borderWidth = Double.parseDouble(parameters);
        } else {
            throw new RuntimeException("Unknown image option " + flagName);
        }
    }
    System.out.println("binary: robust = " + robust + " size = " + size + " grid width = " + gridWidth + " border = " + borderWidth);
    ConfigFiducialBinary configFid = new ConfigFiducialBinary();
    configFid.targetWidth = size;
    configFid.gridWidth = gridWidth;
    configFid.squareDetector.minimumRefineEdgeIntensity = 10;
    configFid.borderWidthFraction = borderWidth;
    ConfigThreshold configThreshold;
    if (robust)
        configThreshold = ConfigThreshold.local(ThresholdType.LOCAL_MEAN, 21);
    else
        configThreshold = ConfigThreshold.fixed(DEFAULT_THRESHOLD);
    detector = FactoryFiducial.squareBinary(configFid, configThreshold, GrayU8.class);
}
Also used : ConfigFiducialBinary(boofcv.factory.fiducial.ConfigFiducialBinary) ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) GrayU8(boofcv.struct.image.GrayU8)

Example 8 with ConfigThreshold

use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.

the class VisualizeBinaryContourApp method imageThresholdUpdated.

@Override
public void imageThresholdUpdated() {
    synchronized (this) {
        ConfigThreshold config = controls.getThreshold().createConfig();
        inputToBinary = FactoryThresholdBinary.threshold(config, getImageType(0).getImageClass());
    }
    reprocessImageOnly();
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold)

Example 9 with ConfigThreshold

use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.

the class FiducialDetection method parseImage.

void parseImage(int index, String[] args) {
    boolean robust = true;
    List<String> paths = new ArrayList<>();
    GrowQueue_F64 sizes = new GrowQueue_F64();
    double borderWidth = 0.25;
    for (; index < args.length; index++) {
        String arg = args[index];
        if (!arg.startsWith("--")) {
            throw new RuntimeException("Expected flags for image fiducial");
        }
        splitFlag(arg);
        if (flagName.compareToIgnoreCase("Robust") == 0) {
            robust = Boolean.parseBoolean(parameters);
        } else if (flagName.compareToIgnoreCase("Image") == 0) {
            String[] words = parameters.split(":");
            if (words.length != 2)
                throw new RuntimeException("Expected two for width and image path");
            sizes.add(Double.parseDouble(words[0]));
            paths.add(words[1]);
        } else if (flagName.compareToIgnoreCase("Border") == 0) {
            borderWidth = Double.parseDouble(parameters);
        } else {
            throw new RuntimeException("Unknown image option " + flagName);
        }
    }
    if (paths.isEmpty())
        throw new RuntimeException("Need to specify patterns");
    System.out.println("image: robust = " + robust + " total patterns = " + paths.size() + " border = " + borderWidth);
    ConfigFiducialImage config = new ConfigFiducialImage();
    config.borderWidthFraction = borderWidth;
    ConfigThreshold configThreshold;
    if (robust)
        configThreshold = ConfigThreshold.local(ThresholdType.LOCAL_MEAN, 21);
    else
        configThreshold = ConfigThreshold.fixed(DEFAULT_THRESHOLD);
    SquareImage_to_FiducialDetector<GrayU8> detector = FactoryFiducial.squareImage(config, configThreshold, GrayU8.class);
    for (int i = 0; i < paths.size(); i++) {
        BufferedImage buffered = UtilImageIO.loadImage(paths.get(i));
        if (buffered == null)
            throw new RuntimeException("Can't find pattern " + paths.get(i));
        GrayU8 pattern = new GrayU8(buffered.getWidth(), buffered.getHeight());
        ConvertBufferedImage.convertFrom(buffered, pattern);
        detector.addPatternImage(pattern, 125, sizes.get(i));
    }
    this.detector = detector;
}
Also used : ArrayList(java.util.ArrayList) GrowQueue_F64(org.ddogleg.struct.GrowQueue_F64) ConfigFiducialImage(boofcv.factory.fiducial.ConfigFiducialImage) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) GrayU8(boofcv.struct.image.GrayU8)

Example 10 with ConfigThreshold

use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.

the class DemoImageThresholdingApp method processImage.

@Override
public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) {
    inputCopy = ConvertBufferedImage.checkCopy(buffered, inputCopy);
    ConfigThreshold config = controlPanel.threshold.createConfig();
    InputToBinary inputToBinary = FactoryThresholdBinary.threshold(config, input.imageType.getImageClass());
    inputToBinary.process(input, imageBinary);
    VisualizeBinaryData.renderBinary(imageBinary, false, visualizedBinary);
    SwingUtilities.invokeLater(() -> {
        controlPanel.threshold.updateHistogram((ImageGray) input);
        changeView();
    });
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) InputToBinary(boofcv.abst.filter.binary.InputToBinary)

Aggregations

ConfigThreshold (boofcv.factory.filter.binary.ConfigThreshold)11 ConfigFiducialBinary (boofcv.factory.fiducial.ConfigFiducialBinary)3 GrayU8 (boofcv.struct.image.GrayU8)3 ConfigFiducialImage (boofcv.factory.fiducial.ConfigFiducialImage)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 BufferedImage (java.awt.image.BufferedImage)2 ArrayList (java.util.ArrayList)2 SquareImage_to_FiducialDetector (boofcv.abst.fiducial.SquareImage_to_FiducialDetector)1 InputToBinary (boofcv.abst.filter.binary.InputToBinary)1 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)1 ConfigThresholdBlockMinMax (boofcv.factory.filter.binary.ConfigThresholdBlockMinMax)1 ConfigThresholdLocalOtsu (boofcv.factory.filter.binary.ConfigThresholdLocalOtsu)1 FactoryShapeDetector (boofcv.factory.shape.FactoryShapeDetector)1 PathLabel (boofcv.io.PathLabel)1 GrayF32 (boofcv.struct.image.GrayF32)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 List (java.util.List)1