当前位置: 首页>>代码示例>>Java>>正文


Java FloodFiller类代码示例

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


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

示例1: fill

import ij.process.FloodFiller; //导入依赖的package包/类
public void fill(ImageProcessor ip, int foreground, int background) {
	int width = ip.getWidth();
	int height = ip.getHeight();
	FloodFiller ff = new FloodFiller(ip);
	ip.setColor(127);
	for (int y=0; y<height; y++) {
		if (ip.getPixel(0,y)==background) ff.fill(0, y);
		if (ip.getPixel(width-1,y)==background) ff.fill(width-1, y);
	}
	for (int x=0; x<width; x++){
		if (ip.getPixel(x,0)==background) ff.fill(x, 0);
		if (ip.getPixel(x,height-1)==background) ff.fill(x, height-1);
	}
	byte[] pixels = (byte[])ip.getPixels();
	int n = width*height;
	for (int i=0; i<n; i++) {
		if (pixels[i]==127)
			pixels[i] = (byte)background;
		else
			pixels[i] = (byte)foreground;
	}
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:23,代码来源:BinaryOrbit.java

示例2: fillHoles

import ij.process.FloodFiller; //导入依赖的package包/类
/**
 * Fill holes in a binary image.
 * 
 * Assumes 255 is foreground, 0 is background.
 * 
 * Based on code in ImageJ's Binary class.
 * 
 * @param bp
 * @return
 */
public static void fillHoles(ByteProcessor bp) {
	int w = bp.getWidth();
	int h = bp.getHeight();
	FloodFiller ff = new FloodFiller(bp);
	bp.setValue(127);
	for (int x = 0; x < w; x++) {
		if (bp.getPixel(x, 0) == 0)
			ff.fill8(x, 0);
		if (bp.getPixel(x, h-1) == 0)
			ff.fill8(x, h-1);
	}
	for (int y = 0; y < h; y++) {
		if (bp.getPixel(0, y) == 0)
			ff.fill8(0, y);
		if (bp.getPixel(w-1, y) == 0)
			ff.fill8(w-1, y);
	}
	for (int i = 0; i < w*h; i++) {
		if (bp.get(i) == 127)
			bp.set(i, 0);
		else
			bp.set(i, 255);
	}
}
 
开发者ID:qupath,项目名称:qupath,代码行数:35,代码来源:ROILabeling.java

示例3: labelImage

import ij.process.FloodFiller; //导入依赖的package包/类
public static ShortProcessor labelImage(ImageProcessor ip, float threshold, boolean conn8) {
	int w = ip.getWidth();
	int h = ip.getHeight();
	short shortMax = (short)65535;
	ShortProcessor sp = new ShortProcessor(w, h);
	short[] pxShort = (short[])sp.getPixels();
	for (int i = 0; i < w*h; i++) {
		if (ip.getf(i) > threshold)
			pxShort[i] = shortMax;
	}
	// Loop through and flood fill
	FloodFiller ff = new FloodFiller(sp);
	double label = 0;
	for (int i = 0; i < pxShort.length; i++) {
		if (pxShort[i] == shortMax) {
			label++;
			sp.setValue(label);
			if (conn8)
				ff.fill8(i % w, i / w);
			else
				ff.fill(i % w, i / w);
		}
	}
	sp.setMinAndMax(0, label);
	return sp;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:27,代码来源:ROILabeling.java

示例4: fill

import ij.process.FloodFiller; //导入依赖的package包/类
/**
 * Fill the image processor closed loops. Only fill background regions defined by the Laplacian image.
 * 
 * @param maskIp
 *            The mask image
 * @param laplacianIp
 *            The original image laplacian
 */
void fill(ImageProcessor maskIp, ImageProcessor laplacianIp)
{
	// TODO - Check the fill option is working ... 

	// Adapted from ij.plugin.binary.Binary.fill(...)
	int background = NONE;
	int width = maskIp.getWidth();
	int height = maskIp.getHeight();
	FloodFiller ff = new FloodFiller(maskIp);
	maskIp.setColor(FILL);
	for (int y = 0; y < height; y++)
	{
		if (maskIp.get(0, y) == background && laplacianIp.get(0, y) < 0)
			ff.fill(0, y);
		if (maskIp.get(width - 1, y) == background && laplacianIp.get(width - 1, y) < 0)
			ff.fill(width - 1, y);
	}
	for (int x = 0; x < width; x++)
	{
		if (maskIp.get(x, 0) == background && laplacianIp.get(x, 0) < 0)
			ff.fill(x, 0);
		if (maskIp.get(x, height - 1) == background && laplacianIp.get(x, height - 1) < 0)
			ff.fill(x, height - 1);
	}

	// Why is the fill reversed?
	//		byte[] pixels = (byte[]) maskIp.getPixels();
	//		int n = width * height;
	//		for (int i = 0; i < n; i++)
	//		{
	//			if (pixels[i] == FILL)
	//				pixels[i] = NONE;
	//			else
	//				pixels[i] = FILL;
	//		}
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:45,代码来源:EdgeMask.java


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