Search in sources :

Example 11 with ListDisplayPanel

use of boofcv.gui.ListDisplayPanel in project BoofCV by lessthanoptimal.

the class ExampleFisheyeToPinhole method main.

public static void main(String[] args) {
    // Path to image data and calibration data
    String fisheyePath = UtilIO.pathExample("fisheye/theta/");
    // load the fisheye camera parameters
    CameraUniversalOmni fisheyeModel = CalibrationIO.load(new File(fisheyePath, "front.yaml"));
    // Specify what the pinhole camera should look like
    CameraPinhole pinholeModel = new CameraPinhole(400, 400, 0, 300, 300, 600, 600);
    // Create the transform from pinhole to fisheye views
    LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel);
    LensDistortionWideFOV fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel);
    NarrowToWidePtoP_F32 transform = new NarrowToWidePtoP_F32(pinholeDistort, fisheyeDistort);
    // Load fisheye RGB image
    BufferedImage bufferedFisheye = UtilImageIO.loadImage(fisheyePath, "front_table.jpg");
    Planar<GrayU8> fisheyeImage = ConvertBufferedImage.convertFrom(bufferedFisheye, true, ImageType.pl(3, GrayU8.class));
    // Create the image distorter which will render the image
    InterpolatePixel<Planar<GrayU8>> interp = FactoryInterpolation.createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, fisheyeImage.getImageType());
    ImageDistort<Planar<GrayU8>, Planar<GrayU8>> distorter = FactoryDistort.distort(false, interp, fisheyeImage.getImageType());
    // Pass in the transform created above
    distorter.setModel(new PointToPixelTransform_F32(transform));
    // Render the image.  The camera will have a rotation of 0 and will thus be looking straight forward
    Planar<GrayU8> pinholeImage = fisheyeImage.createNew(pinholeModel.width, pinholeModel.height);
    distorter.apply(fisheyeImage, pinholeImage);
    BufferedImage bufferedPinhole0 = ConvertBufferedImage.convertTo(pinholeImage, null, true);
    // rotate the virtual pinhole camera to the right
    transform.setRotationWideToNarrow(ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, 0.8f, 0, 0, null));
    distorter.apply(fisheyeImage, pinholeImage);
    BufferedImage bufferedPinhole1 = ConvertBufferedImage.convertTo(pinholeImage, null, true);
    // Display the results
    ListDisplayPanel panel = new ListDisplayPanel();
    panel.addImage(bufferedPinhole0, "Pinehole Forward");
    panel.addImage(bufferedPinhole1, "Pinehole Right");
    panel.addImage(bufferedFisheye, "Fisheye");
    panel.setPreferredSize(new Dimension(600, 450));
    ShowImages.showWindow(panel, "Fisheye to Pinhole", true);
}
Also used : LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) ListDisplayPanel(boofcv.gui.ListDisplayPanel) CameraPinhole(boofcv.struct.calib.CameraPinhole) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) LensDistortionUniversalOmni(boofcv.alg.distort.universal.LensDistortionUniversalOmni) File(java.io.File)

Example 12 with ListDisplayPanel

use of boofcv.gui.ListDisplayPanel in project BoofCV by lessthanoptimal.

the class ExampleRemoveLensDistortion method displayResults.

/**
 * Displays results in a window for easy comparison..
 */
private static void displayResults(BufferedImage orig, Planar<GrayF32> distortedImg, ImageDistort allInside, ImageDistort fullView) {
    // render the results
    Planar<GrayF32> undistortedImg = new Planar<>(GrayF32.class, distortedImg.getWidth(), distortedImg.getHeight(), distortedImg.getNumBands());
    allInside.apply(distortedImg, undistortedImg);
    BufferedImage out1 = ConvertBufferedImage.convertTo(undistortedImg, null, true);
    fullView.apply(distortedImg, undistortedImg);
    BufferedImage out2 = ConvertBufferedImage.convertTo(undistortedImg, null, true);
    // display in a single window where the user can easily switch between images
    ListDisplayPanel panel = new ListDisplayPanel();
    panel.addItem(new ImagePanel(orig), "Original");
    panel.addItem(new ImagePanel(out1), "Undistorted All Inside");
    panel.addItem(new ImagePanel(out2), "Undistorted Full View");
    ShowImages.showWindow(panel, "Removing Lens Distortion", true);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ListDisplayPanel(boofcv.gui.ListDisplayPanel) Planar(boofcv.struct.image.Planar) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ImagePanel(boofcv.gui.image.ImagePanel)

Example 13 with ListDisplayPanel

use of boofcv.gui.ListDisplayPanel in project BoofCV by lessthanoptimal.

the class ExampleImageEnhancement method histogram.

/**
 * Histogram adjustment algorithms aim to spread out pixel intensity values uniformly across the allowed range.
 * This if an image is dark, it will have greater contrast and be brighter.
 */
public static void histogram() {
    BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath));
    GrayU8 gray = ConvertBufferedImage.convertFrom(buffered, (GrayU8) null);
    GrayU8 adjusted = gray.createSameShape();
    int[] histogram = new int[256];
    int[] transform = new int[256];
    ListDisplayPanel panel = new ListDisplayPanel();
    ImageStatistics.histogram(gray, 0, histogram);
    EnhanceImageOps.equalize(histogram, transform);
    EnhanceImageOps.applyTransform(gray, transform, adjusted);
    panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Global");
    EnhanceImageOps.equalizeLocal(gray, 50, adjusted, histogram, transform);
    panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Local");
    panel.addImage(ConvertBufferedImage.convertTo(gray, null), "Original");
    panel.setPreferredSize(new Dimension(gray.width, gray.height));
    mainPanel.addItem(panel, "Histogram");
}
Also used : ListDisplayPanel(boofcv.gui.ListDisplayPanel) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 14 with ListDisplayPanel

use of boofcv.gui.ListDisplayPanel in project BoofCV by lessthanoptimal.

the class ExampleImageEnhancement method sharpen.

/**
 * When an image is sharpened the intensity of edges are made more extreme while flat regions remain unchanged.
 */
public static void sharpen() {
    BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath));
    GrayU8 gray = ConvertBufferedImage.convertFrom(buffered, (GrayU8) null);
    GrayU8 adjusted = gray.createSameShape();
    ListDisplayPanel panel = new ListDisplayPanel();
    EnhanceImageOps.sharpen4(gray, adjusted);
    panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Sharpen-4");
    EnhanceImageOps.sharpen8(gray, adjusted);
    panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Sharpen-8");
    panel.addImage(ConvertBufferedImage.convertTo(gray, null), "Original");
    panel.setPreferredSize(new Dimension(gray.width, gray.height));
    mainPanel.addItem(panel, "Sharpen");
}
Also used : ListDisplayPanel(boofcv.gui.ListDisplayPanel) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 15 with ListDisplayPanel

use of boofcv.gui.ListDisplayPanel in project BoofCV by lessthanoptimal.

the class ExampleWaveletDenoise method main.

public static void main(String[] args) {
    // load the input image, declare data structures, create a noisy image
    Random rand = new Random(234);
    GrayF32 input = UtilImageIO.loadImage(UtilIO.pathExample("standard/lena512.jpg"), GrayF32.class);
    GrayF32 noisy = input.clone();
    GImageMiscOps.addGaussian(noisy, rand, 20, 0, 255);
    GrayF32 denoised = noisy.createSameShape();
    // How many levels in wavelet transform
    int numLevels = 4;
    // Create the noise removal algorithm
    WaveletDenoiseFilter<GrayF32> denoiser = FactoryImageDenoise.waveletBayes(GrayF32.class, numLevels, 0, 255);
    // remove noise from the image
    denoiser.process(noisy, denoised);
    // display the results
    ListDisplayPanel gui = new ListDisplayPanel();
    gui.addImage(ConvertBufferedImage.convertTo(input, null), "Input");
    gui.addImage(ConvertBufferedImage.convertTo(noisy, null), "Noisy");
    gui.addImage(ConvertBufferedImage.convertTo(denoised, null), "Denoised");
    ShowImages.showWindow(gui, "Wavelet Noise Removal Example", true);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ListDisplayPanel(boofcv.gui.ListDisplayPanel) Random(java.util.Random)

Aggregations

ListDisplayPanel (boofcv.gui.ListDisplayPanel)30 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)27 BufferedImage (java.awt.image.BufferedImage)27 GrayU8 (boofcv.struct.image.GrayU8)16 GrayF32 (boofcv.struct.image.GrayF32)14 File (java.io.File)6 CameraPinhole (boofcv.struct.calib.CameraPinhole)4 Planar (boofcv.struct.image.Planar)4 ConfigPolygonDetector (boofcv.factory.shape.ConfigPolygonDetector)3 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)2 FoundFiducial (boofcv.alg.fiducial.square.FoundFiducial)2 Contour (boofcv.alg.filter.binary.Contour)2 FactoryShapeDetector (boofcv.factory.shape.FactoryShapeDetector)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 StereoParameters (boofcv.struct.calib.StereoParameters)2 GrayS16 (boofcv.struct.image.GrayS16)2 GrayS32 (boofcv.struct.image.GrayS32)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 FDistort (boofcv.abst.distort.FDistort)1 ImageDistort (boofcv.alg.distort.ImageDistort)1