本文整理汇总了Java中boofcv.gui.ListDisplayPanel.addImage方法的典型用法代码示例。如果您正苦于以下问题:Java ListDisplayPanel.addImage方法的具体用法?Java ListDisplayPanel.addImage怎么用?Java ListDisplayPanel.addImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boofcv.gui.ListDisplayPanel
的用法示例。
在下文中一共展示了ListDisplayPanel.addImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sharpen
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
/**
* 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("../data/applet/enhance/dull.jpg");
BufferedImage buffered = UtilImageIO.loadImage("../data/applet/enhance/dark.jpg");
ImageUInt8 gray = ConvertBufferedImage.convertFrom(buffered,(ImageUInt8)null);
ImageUInt8 adjusted = new ImageUInt8(gray.width, gray.height);
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));
ShowImages.showWindow(panel,"Sharpen");
}
示例2: run
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
private void run() throws IOException {
BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("C:\\development\\readySET\\deck\\1221.png"));
GrayU8 gray = ConvertBufferedImage.convertFrom(image,(GrayU8)null);
GrayU8 edgeImage = gray.createSameShape();
// Create a canny edge detector which will dynamically compute the threshold based on maximum edge intensity
// It has also been configured to save the trace as a graph. This is the graph created while performing
// hysteresis thresholding.
CannyEdge<GrayU8,GrayS16> canny = FactoryEdgeDetectors.canny(2,true, true, GrayU8.class, GrayS16.class);
// The edge image is actually an optional parameter. If you don't need it just pass in null
canny.process(gray,0.1f,0.3f,edgeImage);
// First get the contour created by canny
List<EdgeContour> edgeContours = canny.getContours();
// The 'edgeContours' is a tree graph that can be difficult to process. An alternative is to extract
// the contours from the binary image, which will produce a single loop for each connected cluster of pixels.
// Note that you are only interested in verticesnal contours.
List<Contour> contours = BinaryImageOps.contour(edgeImage, ConnectRule.EIGHT, null);
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(edgeImage, false, null);
BufferedImage visualCannyContour = VisualizeBinaryData.renderContours(edgeContours,null,
gray.width,gray.height,null);
BufferedImage visualEdgeContour = new BufferedImage(gray.width, gray.height,BufferedImage.TYPE_INT_RGB);
VisualizeBinaryData.render(contours, (int[]) null, visualEdgeContour);
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(visualBinary,"Binary Edges from Canny");
panel.addImage(visualCannyContour, "Canny Trace Graph");
panel.addImage(visualEdgeContour,"Contour from Canny Binary");
ShowImages.showWindow(panel,"Canny Edge", true);
}
示例3: main
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
public static void main( String args[] ) {
// load the input image, declare data structures, create a noisy image
Random rand = new Random(234);
String dir = new File(".").getAbsolutePath();
File file = new File("/Users/mehdibenchoufi/Downloads/Example_lena_denoise_noisy.jpg");
ImageFloat32 input = UtilImageIO.loadImage(file.getAbsolutePath(), ImageFloat32.class);
ImageFloat32 noisy = input.clone();
GImageMiscOps.addGaussian(noisy, rand, 20, 0, 255);
ImageFloat32 denoised = new ImageFloat32(input.width, input.height);
// How many levels in wavelet transform
int numLevels = 4;
// Create the noise removal algorithm
WaveletDenoiseFilter<ImageFloat32> denoiser =
FactoryImageDenoise.waveletBayes(ImageFloat32.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(input, "With noise", true);
ShowImages.showWindow(denoised, "Without noise", true);
}
示例4: main
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
public static void main( String args[] ) {
// load the input image, declare data structures, create a noisy image
Random rand = new Random(234);
ImageFloat32 input = UtilImageIO.loadImage("../data/evaluation/standard/lena512.bmp",ImageFloat32.class);
ImageFloat32 noisy = input.clone();
GImageMiscOps.addGaussian(noisy, rand, 20, 0, 255);
ImageFloat32 denoised = new ImageFloat32(input.width,input.height);
// How many levels in wavelet transform
int numLevels = 4;
// Create the noise removal algorithm
WaveletDenoiseFilter<ImageFloat32> denoiser =
FactoryImageDenoise.waveletBayes(ImageFloat32.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");
}
示例5: main
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
public static void main( String args[] ) {
BufferedImage input = UtilImageIO.loadImage(fileName);
ImageFloat32 inputF32 = ConvertBufferedImage.convertFrom(input,(ImageFloat32)null);
ImageFloat32 integral = IntegralImageOps.transform(inputF32,null);
ImageFloat32 intensity = new ImageFloat32(integral.width,integral.height);
ListDisplayPanel guiIntensity = new ListDisplayPanel();
guiIntensity.addImage(input,"Original");
guiIntensity.addImage(VisualizeImageData.grayMagnitude(inputF32,null,255),"Gray");
int skip = 0;
for( int octave = 0; octave < 4; octave++ ) {
if( skip == 0 )
skip = 1;
else
skip = skip+skip;
for( int sizeIndex = 0; sizeIndex< 4; sizeIndex++ ) {
int block = 1+skip*2*(sizeIndex+1);
int size = 3*block;
IntegralImageFeatureIntensity.hessian(integral,1,size,intensity);
float maxAbs = ImageStatistics.maxAbs(intensity);
BufferedImage b = VisualizeImageData.colorizeSign(intensity,null,maxAbs);
guiIntensity.addImage(b,String.format("Oct = %2d size %3d",octave+1,size));
}
}
ShowImages.showWindow(guiIntensity,"Feature Intensity");
}
示例6: find
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
@Override
public double[] find(BufferedImage image, boolean debug) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Shape> shapes = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(3) // this is fairly critical
.edges()
.dilate()
.contours()
.polygons(0.05, 0.05)
.getExternalShapes();
int expectedWidth = 40 * 3; // 40mm
int expectedHeight = 20 * 3; // 20mm
int tolerancePct = 40;
List<Shape> filtered = GeometryUtils.filterByArea(shapes, expectedWidth, expectedHeight, tolerancePct);
List<Shape> nonOverlapping = GeometryUtils.filterNonOverlappingBoundingBoxes(filtered);
Optional<RectangleLength2D_F32> box = nonOverlapping.stream()
.map(Shape::getBoundingBox)
.findFirst();
double[] features = null;
if (box.isPresent()) {
Quadrilateral_F64 quad = new Quadrilateral_F64();
RectangleLength2D_F32 rect = box.get();
convert(rect, quad);
Planar<GrayF32> output = GeometryUtils.removePerspectiveDistortion(image, quad, 200, 100);
BufferedImage shape = ConvertBufferedImage.convertTo_F32(output, null, true);
if (debug) {
panel.addImage(shape, "Shape");
}
ImageProcessingPipeline.ContourPolygonsProcessor edgeProcessor = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.edges()
.contours()
.polygons(0.01, 0.01);
ImageProcessingPipeline.ContourPolygonsProcessor binaryProcessor = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.binarize(0, 255, true)
.contours()
.polygons(0.01, 0.01);
GrayU8 finalImage = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.sharpen()
.binarize(0, 255, true)
.extract(100 - 25, 50 - 12, 50, 25)
.getImage();
double meanPixelValue = ImageStatistics.mean(finalImage);
features = new double[] { meanPixelValue };
}
if (debug) {
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return features;
}
示例7: detect
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
public List<CardImage> detect(BufferedImage image, String filename, boolean debug, boolean allowRotated, int expectedRows, int expectedColumns) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
String imageInfo = filename == null ? image.toString() : filename;
if (!allowRotated && image.getWidth() > image.getHeight()) {
throw new IllegalArgumentException("Image height must be greater than width: " + imageInfo);
}
int medianBlur = this.medianBlur != -1 ? this.medianBlur : Math.max(image.getHeight(), image.getWidth()) / 200; // heuristic
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Quadrilateral_F64> quads = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(medianBlur)
.binarize(0, 255)
.erode()
.dilate()
.contours()
.polygons(0.05, 0.1)
.getExternalQuadrilaterals();
// Only include shapes that are within given percentage of the mean area. This filters out image artifacts that
// happen to be quadrilaterals that are not cards (since they are usually a different size).
List<Quadrilateral_F64> cards = GeometryUtils.filterByArea(quads, areaTolerancePct);
List<List<Quadrilateral_F64>> rows = GeometryUtils.sortRowWise(cards);// sort into a stable order
if (expectedRows != -1 && rows.size() != expectedRows) {
throw new IllegalArgumentException(String.format("Expected %s rows, but detected %s: %s", expectedRows, rows.size(), imageInfo));
}
if (expectedColumns != -1) {
rows.forEach(row -> {
if (row.size() != expectedColumns) {
throw new IllegalArgumentException(String.format("Expected %s columns, but detected %s: %s", expectedColumns, row.size(), imageInfo));
}
});
}
List<CardImage> cardImages = rows.stream()
.flatMap(List::stream)
.map(q -> {
// Remove perspective distortion
Planar<GrayF32> output = GeometryUtils.removePerspectiveDistortion(image, q, 57 * 3, 89 * 3); // actual cards measure 57 mm x 89 mm
BufferedImage im = ConvertBufferedImage.convertTo_F32(output, null, true);
return new CardImage(im, q);
}
).collect(Collectors.toList());
if (debug) {
int i = 1;
for (CardImage card : cardImages) {
panel.addImage(card.getImage(), "Card " + i++);
}
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return cardImages;
}
示例8: main
import boofcv.gui.ListDisplayPanel; //导入方法依赖的package包/类
/**
* The main method.
*
* @param args the arguments
*/
public static void main( String args[] ) {
// load and convert the image into a usable format
BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("/home/pete/development/gitrepo/iote2e/iote2e-tests/images/iote2e-test.png"));
// convert into a usable format
GrayF32 input = ConvertBufferedImage.convertFromSingle(image, null, GrayF32.class);
GrayU8 binary = new GrayU8(input.width,input.height);
GrayS32 label = new GrayS32(input.width,input.height);
// Select a global threshold using Otsu's method.
double threshold = GThresholdImageOps.computeOtsu(input, 0, 255);
// Apply the threshold to create a binary image
ThresholdImageOps.threshold(input,binary,(float)threshold,true);
// remove small blobs through erosion and dilation
// The null in the input indicates that it should internally declare the work image it needs
// this is less efficient, but easier to code.
GrayU8 filtered = BinaryImageOps.erode8(binary, 1, null);
filtered = BinaryImageOps.dilate8(filtered, 1, null);
// Detect blobs inside the image using an 8-connect rule
List<Contour> contours = BinaryImageOps.contour(filtered, ConnectRule.EIGHT, label);
// colors of contours
int colorExternal = 0xFFFFFF;
int colorInternal = 0xFF2020;
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(binary, false, null);
BufferedImage visualFiltered = VisualizeBinaryData.renderBinary(filtered, false, null);
BufferedImage visualLabel = VisualizeBinaryData.renderLabeledBG(label, contours.size(), null);
BufferedImage visualContour = VisualizeBinaryData.renderContours(contours, colorExternal, colorInternal,
input.width, input.height, null);
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(visualBinary, "Binary Original");
panel.addImage(visualFiltered, "Binary Filtered");
panel.addImage(visualLabel, "Labeled Blobs");
panel.addImage(visualContour, "Contours");
ShowImages.showWindow(panel,"Binary Operations",true);
}