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();
}
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);
}
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();
}
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;
}
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();
});
}
Aggregations