本文整理汇总了Java中boofcv.gui.binary.VisualizeBinaryData.renderBinary方法的典型用法代码示例。如果您正苦于以下问题:Java VisualizeBinaryData.renderBinary方法的具体用法?Java VisualizeBinaryData.renderBinary怎么用?Java VisualizeBinaryData.renderBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boofcv.gui.binary.VisualizeBinaryData
的用法示例。
在下文中一共展示了VisualizeBinaryData.renderBinary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public void process( BufferedImage image ) {
I input = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
I blur = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFromSingle(image, input, imageType);
GBlurImageOps.gaussian(input, blur, -1, 2, null);
DetectLineHoughFoot<I,D> alg = FactoryDetectLineAlgs.houghFoot(6, 12, 5, 25, 10, imageType, derivType);
ImageLinePanel gui = new ImageLinePanel();
gui.setBackground(image);
gui.setLines(alg.detect(blur));
gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));
BufferedImage renderedTran = VisualizeImageData.grayMagnitude(alg.getTransform().getTransform(),null,-1);
BufferedImage renderedBinary = VisualizeBinaryData.renderBinary(alg.getBinary(), null);
ShowImages.showWindow(renderedBinary,"Detected Edges");
ShowImages.showWindow(renderedTran,"Parameter Space");
ShowImages.showWindow(gui,"Detected Lines");
}
示例2: process
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public void process( BufferedImage image ) {
I input = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
I blur = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFromSingle(image, input, imageType);
GBlurImageOps.gaussian(input, blur, -1, 2, null);
DetectLineHoughPolar<I,D> alg = FactoryDetectLineAlgs.houghPolar(5, 10, 2, Math.PI / 180, 25, 10, imageType, derivType);
List<LineParametric2D_F32> lines = alg.detect(blur);
ImageLinePanel gui = new ImageLinePanel();
gui.setBackground(image);
gui.setLines(lines);
gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));
BufferedImage renderedTran = VisualizeImageData.grayMagnitude(alg.getTransform().getTransform(),null,-1);
BufferedImage renderedBinary = VisualizeBinaryData.renderBinary(alg.getBinary(), null);
ShowImages.showWindow(renderedBinary,"Detected Edges");
ShowImages.showWindow(renderedTran,"Parameter Space");
ShowImages.showWindow(gui,"Detected Lines");
}
示例3: actionPerformed
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if( e.getSource() == imagesCombo ) {
int index = imagesCombo.getSelectedIndex();
if( index == 0 ) {
selectedVisualize = imageBinary;
} else {
selectedVisualize = imageOutput;
}
if( work != null ) {
VisualizeBinaryData.renderBinary(selectedVisualize, work);
gui.repaint();
}
} else {
super.actionPerformed(e);
}
}
示例4: run
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的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);
}
示例5: generateBlackWhiteImage
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
static BufferedImage generateBlackWhiteImage(String path, boolean save) throws IOException {
BufferedImage in = ImageIO.read(new File(path));
// convert into a usable format
GrayF32 input = ConvertBufferedImage.convertFromSingle(in, 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);
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(binary, false, null);
if (save) { // Save the image, if necessary
File outputfile = new File("saved.png");
ImageIO.write(visualBinary, "png", outputfile);
}
System.out.println("Done with part 1!");
return visualBinary;
}
示例6: getEdgeImg
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public static MultiImage getEdgeImg(MultiImage img) {
LOGGER.traceEntry();
GrayU8 gray = ConvertBufferedImage.convertFrom(img.getBufferedImage(), (GrayU8) null);
if(!isSolid(gray)){
getCanny().process(gray, THRESHOLD_LOW, THRESHOLD_HIGH, gray);
}
BufferedImage bout = VisualizeBinaryData.renderBinary(gray, false, null);
return LOGGER.traceExit(MultiImageFactory.newMultiImage(bout));
}
示例7: main
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public static void main( String args[] ) {
BufferedImage image = UtilImageIO.loadImage("../data/applet/simple_objects.jpg");
ImageUInt8 gray = ConvertBufferedImage.convertFrom(image,(ImageUInt8)null);
ImageUInt8 edgeImage = new ImageUInt8(gray.width,gray.height);
// 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<ImageUInt8,ImageSInt16> canny = FactoryEdgeDetectors.canny(2,true, true, ImageUInt8.class, ImageSInt16.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 external contours.
List<Contour> contours = BinaryImageOps.contour(edgeImage, 8, null);
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(edgeImage, null);
BufferedImage visualCannyContour = VisualizeBinaryData.renderContours(edgeContours,null,
gray.width,gray.height,null);
BufferedImage visualEdgeContour = VisualizeBinaryData.renderExternal(contours, null,
gray.width, gray.height, null);
ShowImages.showWindow(visualBinary,"Binary Edges from Canny");
ShowImages.showWindow(visualCannyContour,"Canny Trace Graph");
ShowImages.showWindow(visualEdgeContour,"Contour from Canny Binary");
}
示例8: main
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public static void main( String args[] ) {
// load and convert the image into a usable format
BufferedImage image = UtilImageIO.loadImage("../data/applet/particles01.jpg");
// convert into a usable format
ImageFloat32 input = ConvertBufferedImage.convertFromSingle(image, null, ImageFloat32.class);
ImageUInt8 binary = new ImageUInt8(input.width,input.height);
ImageSInt32 label = new ImageSInt32(input.width,input.height);
// the mean pixel value is often a reasonable threshold when creating a binary image
double mean = ImageStatistics.mean(input);
// create a binary image by thresholding
ThresholdImageOps.threshold(input,binary,(float)mean,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.
ImageUInt8 filtered = BinaryImageOps.erode8(binary,null);
filtered = BinaryImageOps.dilate8(filtered, null);
// Detect blobs inside the image using an 8-connect rule
List<Contour> contours = BinaryImageOps.contour(filtered, 8, label);
// colors of contours
int colorExternal = 0xFFFFFF;
int colorInternal = 0xFF2020;
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(binary, null);
BufferedImage visualFiltered = VisualizeBinaryData.renderBinary(filtered, null);
BufferedImage visualLabel = VisualizeBinaryData.renderLabeled(label, contours.size(), null);
BufferedImage visualContour = VisualizeBinaryData.renderContours(contours,colorExternal,colorInternal,
input.width,input.height,null);
ShowImages.showWindow(visualBinary,"Binary Original");
ShowImages.showWindow(visualFiltered,"Binary Filtered");
ShowImages.showWindow(visualLabel,"Labeled Blobs");
ShowImages.showWindow(visualContour,"Contours");
}
示例9: ImageBinaryPanel
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public ImageBinaryPanel( ImageUInt8 binaryImage ) {
this.binaryImage = binaryImage;
img = new BufferedImage(binaryImage.getWidth(),binaryImage.getHeight(),BufferedImage.TYPE_BYTE_GRAY);
VisualizeBinaryData.renderBinary(binaryImage,img);
setPreferredSize(new Dimension(binaryImage.getWidth(), binaryImage.getHeight()));
setMinimumSize(getPreferredSize());
setMaximumSize(getPreferredSize());
}
示例10: main
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public static void main( String args[] ){
BufferedImage input = UtilImageIO.loadImage(fileName);
ImageFloat32 inputF32 = ConvertBufferedImage.convertFrom(input,(ImageFloat32)null);
ImageFloat32 blurred = new ImageFloat32(inputF32.width,inputF32.height);
ImageFloat32 derivX = new ImageFloat32(inputF32.width,inputF32.height);
ImageFloat32 derivY = new ImageFloat32(inputF32.width,inputF32.height);
ImageFloat32 intensity = new ImageFloat32(inputF32.width,inputF32.height);
ImageFloat32 orientation = new ImageFloat32(inputF32.width,inputF32.height);
ImageFloat32 suppressed = new ImageFloat32(inputF32.width,inputF32.height);
ImageSInt8 direction = new ImageSInt8(inputF32.width,inputF32.height);
ImageUInt8 output = new ImageUInt8(inputF32.width,inputF32.height);
BlurStorageFilter<ImageFloat32> blur = FactoryBlurFilter.gaussian(ImageFloat32.class,-1,2);
ImageGradient<ImageFloat32,ImageFloat32> gradient = FactoryDerivative.sobel_F32();
blur.process(inputF32,blurred);
gradient.process(blurred,derivX,derivY);
float threshLow = 5;
float threshHigh = 40;
GradientToEdgeFeatures.intensityE(derivX,derivY,intensity);
GradientToEdgeFeatures.direction(derivX,derivY,orientation);
GradientToEdgeFeatures.discretizeDirection4(orientation,direction);
GradientToEdgeFeatures.nonMaxSuppression4(intensity,direction,suppressed);
ShowImages.showWindow(suppressed,"Suppressed Intensity",true);
BufferedImage renderedOrientation = VisualizeEdgeFeatures.renderOrientation4(direction,suppressed,threshLow,null);
HysteresisEdgeTraceMark hysteresis = new HysteresisEdgeTraceMark();
hysteresis.process(suppressed,direction,threshLow,threshHigh,output);
BufferedImage renderedLabel = VisualizeBinaryData.renderBinary(output, null);
ShowImages.showWindow(intensity,"Raw Intensity",true);
ShowImages.showWindow(renderedOrientation,"Orientation");
ShowImages.showWindow(renderedLabel,"Labeled Contours");
}
示例11: main
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的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);
}
示例12: setBinaryImage
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public void setBinaryImage(ImageUInt8 binaryImage) {
this.binaryImage = binaryImage;
VisualizeBinaryData.renderBinary(binaryImage,img);
}
示例13: renderOutput
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
private synchronized void renderOutput() {
switch( calibGUI.getSelectedView() ) {
case 0:
workImage.createGraphics().drawImage(input,null,null);
break;
case 1:
VisualizeBinaryData.renderBinary(alg.getBinary(), workImage);
break;
case 2:
renderClusters();
break;
case 3:
alg.renderIntensity(intensity);
float max = ImageStatistics.maxAbs(intensity);
VisualizeImageData.colorizeSign(intensity,workImage,max);
break;
default:
throw new RuntimeException("Unknown mode");
}
Graphics2D g2 = workImage.createGraphics();
if( foundTarget ) {
if( calibGUI.isShowBound() ) {
ImageRectangle boundary = alg.getFindBound().getBoundRect();
drawBounds(g2, boundary);
}
if( calibGUI.isShowNumbers() ) {
drawNumbers(g2, alg.getPoints(),1);
}
}
if( calibGUI.isShowPoints() ) {
List<Point2D_F64> candidates = alg.getPoints();
for( Point2D_F64 c : candidates ) {
VisualizeFeatures.drawPoint(g2, (int)c.x, (int)c.y, 2, Color.RED);
}
}
if( calibGUI.doShowGraph ) {
List<QuadBlob> graph = alg.getFindBound().getGraphBlobs();
if( graph != null )
DetectCalibrationSquaresApp.drawGraph(g2,graph);
}
gui.setBufferedImage(workImage);
gui.setScale(calibGUI.getScale());
gui.repaint();
processed = true;
}
示例14: renderOutput
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
private synchronized void renderOutput() {
switch( calibGUI.getSelectedView() ) {
case 0:
workImage.createGraphics().drawImage(input,null,null);
break;
case 1:
VisualizeBinaryData.renderBinary(binary, workImage);
break;
case 2:
int numLabels = alg.getNumberOfLabels();
VisualizeBinaryData.renderLabeled(alg.getBlobs(),numLabels,workImage);
break;
default:
throw new RuntimeException("Unknown mode");
}
Graphics2D g2 = workImage.createGraphics();
List<Point2D_F64> targetBounds = alg.getTargetQuadrilateral();
List<Point2D_F64> targetPoints = alg.getInterestPoints();
if( calibGUI.isShowPoints())
drawPoints(g2, targetPoints);
if( foundTarget ) {
if( calibGUI.isShowNumbers())
drawNumbers(g2, targetPoints);
if( calibGUI.isShowGraph())
drawGraph(g2, alg.getInterestSquares());
if( calibGUI.isShowBound())
drawBounds(g2,targetBounds);
calibGUI.setSuccessMessage("FOUND",true);
} else {
drawSquareCorners(g2,alg.getSquaresBad(),Color.BLUE);
calibGUI.setSuccessMessage("FAILED", false);
}
gui.setBufferedImage(workImage);
gui.setScale(calibGUI.getScale());
gui.repaint();
processedImage = true;
}
示例15: process
import boofcv.gui.binary.VisualizeBinaryData; //导入方法依赖的package包/类
public void process( BufferedImage image ) {
int regionSize = 40;
I input = GeneralizedImageOps.createSingleBand(imageType, image.getWidth(), image.getHeight());
D derivX = GeneralizedImageOps.createSingleBand(derivType, image.getWidth(), image.getHeight());
D derivY = GeneralizedImageOps.createSingleBand(derivType, image.getWidth(), image.getHeight());
ImageFloat32 edgeIntensity = new ImageFloat32(input.width,input.height);
ImageFloat32 suppressed = new ImageFloat32(input.width,input.height);
ImageFloat32 orientation = new ImageFloat32(input.width,input.height);
ImageSInt8 direction = new ImageSInt8(input.width,input.height);
ImageUInt8 detected = new ImageUInt8(input.width,input.height);
GridLineModelDistance distance = new GridLineModelDistance((float)(Math.PI*0.75));
GridLineModelFitter fitter = new GridLineModelFitter((float)(Math.PI*0.75));
ModelMatcher<LinePolar2D_F32, Edgel> matcher =
new Ransac<LinePolar2D_F32,Edgel>(123123,fitter,distance,25,1);
ImageGradient<I,D> gradient = FactoryDerivative.sobel(imageType, derivType);
System.out.println("Image width "+input.width+" height "+input.height);
ConvertBufferedImage.convertFromSingle(image, input, imageType);
gradient.process(input, derivX, derivY);
GGradientToEdgeFeatures.intensityAbs(derivX, derivY, edgeIntensity);
// non-max suppression on the lines
// GGradientToEdgeFeatures.direction(derivX,derivY,orientation);
// GradientToEdgeFeatures.discretizeDirection4(orientation,direction);
// GradientToEdgeFeatures.nonMaxSuppression4(edgeIntensity,direction,suppressed);
GThresholdImageOps.threshold(edgeIntensity,detected,30,false);
GridRansacLineDetector<ImageFloat32> alg = new ImplGridRansacLineDetector_F32(40,10,matcher);
alg.process((ImageFloat32) derivX, (ImageFloat32) derivY, detected);
MatrixOfList<LineSegment2D_F32> gridLine = alg.getFoundLines();
ConnectLinesGrid connect = new ConnectLinesGrid(Math.PI*0.01,1,8);
// connect.process(gridLine);
// LineImageOps.pruneClutteredGrids(gridLine,3);
List<LineSegment2D_F32> found = gridLine.createSingleList();
System.out.println("size = "+found.size());
LineImageOps.mergeSimilar(found,(float)(Math.PI*0.03),5f);
// LineImageOps.pruneSmall(found,40);
System.out.println("after size = "+found.size());
ImageLinePanel gui = new ImageLinePanel();
gui.setBackground(image);
gui.setLineSegments(found);
gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight()));
BufferedImage renderedBinary = VisualizeBinaryData.renderBinary(detected, null);
ShowImages.showWindow(renderedBinary,"Detected Edges");
ShowImages.showWindow(gui,"Detected Lines");
}