• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GrayS32类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中boofcv.struct.image.GrayS32的典型用法代码示例。如果您正苦于以下问题:Java GrayS32类的具体用法?Java GrayS32怎么用?Java GrayS32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GrayS32类属于boofcv.struct.image包,在下文中一共展示了GrayS32类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getContours

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
/**
 * Applies a contour-detection algorithm on the provided image and returns a list of detected contours. First, the image
 * is converted to a BinaryImage using a threshold algorithm (Otsu). Afterwards, blobs in the image are detected using
 * an 8-connect rule.
 *
 * @param image BufferedImage in which contours should be detected.
 * @return List of contours.
 */
public static List<Contour> getContours(BufferedImage image) {
    /* Draw a black frame around to image so as to make sure that all detected contours are internal contours. */
    BufferedImage resized = new BufferedImage(image.getWidth() + 4, image.getHeight() + 4, image.getType());
    Graphics g = resized.getGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(0,0,resized.getWidth(),resized.getHeight());
    g.drawImage(image, 2,2, image.getWidth(), image.getHeight(), null);

    /* Convert to BufferedImage to Gray-scale image and prepare Binary image. */
    GrayF32 input = ConvertBufferedImage.convertFromSingle(resized, 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 and apply that threshold. */
    double threshold = GThresholdImageOps.computeOtsu(input, 0, 255);
    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. */
    return BinaryImageOps.contour(filtered, ConnectRule.EIGHT, label);
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:34,代码来源:ContourHelper.java


示例2: generateBlackWhiteImage

import boofcv.struct.image.GrayS32; //导入依赖的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;

}
 
开发者ID:tuomilabs,项目名称:readySET,代码行数:38,代码来源:Test.java


示例3: labeled

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
/**
 * Visualizes a labeled image.  Each label is assigned a random color
 * @param image Labeled input image
 * @return Rendered color output image
 */
public static PImage labeled( GrayS32 image ) {

	int numRegions = ImageStatistics.max(image)+1;

	int colors[] = new int[numRegions];

	Random rand = new Random(123);
	for( int i = 0; i < colors.length; i++ ) {
		colors[i] = rand.nextInt() | 0xFF000000;
	}
	colors[0]= 0xFF000000;

	return labeled(image, colors);
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:20,代码来源:VisualizeProcessing.java


示例4: contour

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
/**
 * Finds the contours of blobs in a binary image.  Uses 8-connect rule
 *
 * @see BinaryImageOps#contour
 */
public ResultsBlob contour() {
	GrayS32 labeled = new GrayS32(image.width,image.height);

	List<Contour> contours = BinaryImageOps.contour(image, ConnectRule.EIGHT, labeled);

	return new ResultsBlob(contours,labeled);
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:13,代码来源:SimpleBinary.java


示例5: addImage

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
public synchronized GrayU8 addImage(GrayU8 newImage, int[][] matrix) {
    int width = newImage.width;
    int height = newImage.height;

    // Изменилось разрешение детектора - пересоздаем всё
    if (oldWidth != width || oldHeight != height) {
        //oldGrey = null;
        oldWidth = width;
        oldHeight = height;
        segmented = new GrayU8(oldWidth, oldHeight);
        homeToWorld.a13 = width / 2;
        homeToWorld.a23 = height / 2;

        background.initialize(width * 2, height * 2, homeToWorld);
        labeledObjects = new GrayS32(width, height);
    }

    background.segment(firstToCurrent32, newImage, segmented);
    background.updateBackground(firstToCurrent32, newImage);

    BinaryImageOps.removePointNoise(segmented, segmented);
    List<Contour> contours = BinaryImageOps.contour(segmented, ConnectRule.EIGHT, labeledObjects);

    int bigObjects = 0;
    if (contours.size() > 0) {
        for (Contour c : contours) {
            int minx = Integer.MAX_VALUE;
            int miny = Integer.MAX_VALUE;
            int maxx = Integer.MIN_VALUE;
            int maxy = Integer.MIN_VALUE;
            for (Point2D_I32 point : c.external) {
                if (minx > point.getX()) {
                    minx = point.getX();
                }
                if (maxx < point.getX()) {
                    maxx = point.getX();
                }
                if (miny > point.getY()) {
                    miny = point.getY();
                }
                if (maxy < point.getY()) {
                    maxy = point.getY();
                }
            }
            int length = Math.min((maxx - minx), (maxy - miny));
            //System.out.println("Length: " + length);
            if (length > 5) {
                if (checkMatrix(width, height, matrix, minx, maxx, miny, maxy)) {
                    bigObjects++;
                }
            }
        }
        if (bigObjects > 0) {
            return segmented;
        }
    }
    return null;
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:59,代码来源:MotionDetector.java


示例6: main

import boofcv.struct.image.GrayS32; //导入依赖的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);
}
 
开发者ID:petezybrick,项目名称:iote2e,代码行数:48,代码来源:ExampleBinaryOps.java


示例7: SimpleLabeledImage

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
public SimpleLabeledImage(GrayS32 image) {
	super(image);
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:4,代码来源:SimpleLabeledImage.java


示例8: ResultsBlob

import boofcv.struct.image.GrayS32; //导入依赖的package包/类
public ResultsBlob(List<Contour> contour, GrayS32 labeled) {
	this.contour = contour;
	this.labeled = labeled;
}
 
开发者ID:lessthanoptimal,项目名称:BoofProcessing,代码行数:5,代码来源:ResultsBlob.java



注:本文中的boofcv.struct.image.GrayS32类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StringsCompleter类代码示例发布时间:2022-05-22
下一篇:
Java VTDNavHuge类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap