use of boofcv.abst.disparity.ConfigSpeckleFilter in project BoofCV by lessthanoptimal.
the class DemoThreeViewControls method addDisparityControls.
private void addDisparityControls() {
ConfigDisparityBMBest5 configBM = new ConfigDisparityBMBest5();
ConfigDisparitySGM configSGM = new ConfigDisparitySGM();
ConfigSpeckleFilter configSpeckle = new ConfigSpeckleFilter();
configBM.disparityMin = configSGM.disparityMin = 0;
configBM.disparityRange = configSGM.disparityRange = 200;
configBM.regionRadiusX = configBM.regionRadiusY = 4;
configBM.errorType = DisparityError.CENSUS;
configBM.configCensus.variant = CensusVariants.BLOCK_7_7;
controlDisparity = new ControlPanelDisparityDense(configBM, configSGM, configSpeckle, GrayU8.class);
controlDisparity.setListener(this::handleStereoChanged);
}
use of boofcv.abst.disparity.ConfigSpeckleFilter in project BoofCV by lessthanoptimal.
the class ExampleStereoDisparitySmoothing method main.
public static void main(String[] args) {
String calibDir = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess/");
String imageDir = UtilIO.pathExample("stereo/");
StereoParameters param = CalibrationIO.load(new File(calibDir, "stereo.yaml"));
// load and convert images into a BoofCV format
BufferedImage origLeft = UtilImageIO.loadImage(imageDir, "chair01_left.jpg");
BufferedImage origRight = UtilImageIO.loadImage(imageDir, "chair01_right.jpg");
GrayU8 distLeft = ConvertBufferedImage.convertFrom(origLeft, (GrayU8) null);
GrayU8 distRight = ConvertBufferedImage.convertFrom(origRight, (GrayU8) null);
// rectify images
GrayU8 rectLeft = distLeft.createSameShape();
GrayU8 rectRight = distRight.createSameShape();
// Using a previous example, rectify then compute the disparity image
RectifyCalibrated rectifier = ExampleStereoDisparity.rectify(distLeft, distRight, param, rectLeft, rectRight);
GrayF32 disparity = ExampleStereoDisparity.denseDisparitySubpixel(rectLeft, rectRight, 5, 10, disparityRange);
// Let's show the results in a single window before speckle is "removed"
var gui = new ListDisplayPanel();
gui.addImage("Before", VisualizeImageData.disparity(disparity, null, disparityRange, 0));
gui.addItem("Before 3D", ExampleStereoDisparity3D.computeAndShowCloud(param, rectLeft, rectifier, disparity));
// Here's what we came here for. Time to remove the speckle
var configSpeckle = new ConfigSpeckleFilter();
// Two pixels are connected if their disparity is this similar
configSpeckle.similarTol = 1.0f;
// probably the most important parameter, speckle size
configSpeckle.maximumArea.setFixed(200);
DisparitySmoother<GrayU8, GrayF32> smoother = FactoryStereoDisparity.removeSpeckle(configSpeckle, GrayF32.class);
smoother.process(rectLeft, disparity, disparityRange);
gui.addImage("After", VisualizeImageData.disparity(disparity, null, disparityRange, 0));
gui.addItem("After 3D", ExampleStereoDisparity3D.computeAndShowCloud(param, rectLeft, rectifier, disparity));
// Notice how in the "After 3D" view the number of randomly floating points is much less?
ShowImages.showWindow(gui, "Disparity Smoothing", true);
}
Aggregations