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


Java ByteProcessor.set方法代码示例

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


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

示例1: getThreshold

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor getThreshold(ByteProcessor I) {
	int w = I.getWidth();
	int h = I.getHeight();
	makeMeanAndVariance(I, params);
	ByteProcessor Q = new ByteProcessor(w, h);
	final double kappa = params.kappa;
	final int dMin = params.dMin;
	final boolean darkBg = (params.bgMode == BackgroundMode.DARK);
	
	for (int v = 0; v < h; v++) {
		for (int u = 0; u < w; u++) {
			double sigma = Isigma.getf(u, v);
			double mu = Imean.getf(u, v);
			double diff = kappa * sigma + dMin;
			int q = (int) Math.rint((darkBg) ? mu + diff : mu - diff);
			if (q < 0)	 q = 0;
			if (q > 255) q = 255;
			Q.set(u, v, q);
		}
	}
	return Q;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:24,代码来源:NiblackThresholder.java

示例2: savePixels

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Save the provided pixels as optional glyphs.
 *
 * @param box   the absolute bounding box of inter descriptor (perhaps larger than symbol)
 * @param fores foreground pixels with coordinates relative to descriptor bounding box
 */
private void savePixels (Rectangle box,
                         List<Point> fores)
{
    ByteProcessor buf = new ByteProcessor(box.width, box.height);
    ByteUtil.raz(buf); // buf.invert();

    for (Point p : fores) {
        buf.set(p.x, p.y, 0);
    }

    // Runs
    RunTableFactory factory = new RunTableFactory(SYMBOL_ORIENTATION);
    RunTable runTable = factory.createTable(buf);

    // Glyphs
    List<Glyph> glyphs = GlyphFactory.buildGlyphs(
            runTable,
            new Point(0, 0),
            Group.SYMBOL);

    systemWeaks.addAll(glyphs);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:29,代码来源:SymbolsFilter.java

示例3: createBuffer

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private static ByteProcessor createBuffer (BufferedImage img)
{
    DataBuffer dataBuffer = img.getData().getDataBuffer();
    ByteProcessor buf = new ByteProcessor(img.getWidth(), img.getHeight());

    for (int y = 0, h = img.getHeight(); y < h; y++) {
        for (int x = 0, w = img.getWidth(); x < w; x++) {
            int index = x + (y * w);
            int elem = dataBuffer.getElem(index);

            // ShapeSymbol instances use alpha channel as the pixel level
            // With 0 as totally transparent so background (255)
            // And with 255 as totally opaque so foreground (0)
            int val = 255 - (elem >>> 24);
            buf.set(x, y, val);
        }
    }

    // binarize
    buf.threshold(216);

    return buf;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:24,代码来源:SymbolSample.java

示例4: filteredImage

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor filteredImage ()
{
    ByteProcessor ip = new ByteProcessor(source.getWidth(), source.getHeight());

    for (int x = 0, w = ip.getWidth(); x < w; x++) {
        for (int y = 0, h = ip.getHeight(); y < h; y++) {
            if (isFore(x, y)) {
                ip.set(x, y, FOREGROUND);
            } else {
                ip.set(x, y, BACKGROUND);
            }
        }
    }

    return ip;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:18,代码来源:AdaptiveFilter.java

示例5: filteredImage

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor filteredImage ()
{
    ByteProcessor ip = new ByteProcessor(source.getWidth(), source.getHeight());

    for (int y = 0, h = ip.getHeight(); y < h; y++) {
        for (int x = 0, w = ip.getWidth(); x < w; x++) {
            if (isFore(x, y)) {
                ip.set(x, y, FOREGROUND);
            } else {
                ip.set(x, y, BACKGROUND);
            }
        }
    }

    return ip;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:18,代码来源:GlobalFilter.java

示例6: getBuffer

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Fill a rectangular buffer with the table runs
 *
 * @return the filled buffer
 */
public ByteProcessor getBuffer ()
{
    // Determine the bounding box
    final ByteProcessor buffer = new ByteProcessor(width, height);
    ByteUtil.raz(buffer); // buffer.invert();

    for (int iSeq = 0, size = getSize(); iSeq < size; iSeq++) {
        for (Itr it = new Itr(iSeq); it.hasNext();) {
            final Run run = it.next();

            for (int coord = run.getStart(), stop = run.getStop(); coord <= stop; coord++) {
                if (orientation == HORIZONTAL) {
                    buffer.set(coord, iSeq, 0);
                } else {
                    buffer.set(iSeq, coord, 0);
                }
            }
        }
    }

    return buffer;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:28,代码来源:RunTable.java

示例7: write

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Write the table at proper offset in provided buffer
 *
 * @param buffer  the buffer to be written to
 * @param xOffset relative buffer abscissa for runTable topLeft corner
 * @param yOffset relative buffer ordinate for runTable topLeft corner
 */
public void write (ByteProcessor buffer,
                   int xOffset,
                   int yOffset)
{
    final boolean isVertical = orientation == Orientation.VERTICAL;

    for (int iSeq = 0, size = getSize(); iSeq < size; iSeq++) {
        for (Iterator<Run> it = iterator(iSeq); it.hasNext();) {
            final Run run = it.next();

            for (int coord = run.getStart(), stop = run.getStop(); coord <= stop; coord++) {
                if (isVertical) {
                    buffer.set(xOffset + iSeq, yOffset + coord, 0);
                } else {
                    buffer.set(xOffset + coord, yOffset + iSeq, 0);
                }
            }
        }
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:28,代码来源:RunTable.java

示例8: markSeedPoints

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private static int markSeedPoints(final Region region, final ByteProcessor seedImage, final int regionId) {

        int seedCount = 0;
        for (final SubRegion subRegion : region.getSubRegions()) {
            final Roi roi = subRegion.getRoi();
            final Rectangle bounds = roi.getBounds();
            for (int y = bounds.y; y < bounds.y + bounds.height; y++) {
                for (int x = bounds.x; x < bounds.x + bounds.width; x++) {
                    if (roi.contains(x, y) && seedImage.get(x, y) == 0) {
                        seedImage.set(x, y, regionId);
                        seedCount++;
                    }
                }
            }
        }

        return seedCount;
    }
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:19,代码来源:RegionGrowingModel.java

示例9: convertToBinary

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private ImagePlus convertToBinary(final ImagePlus imp, final double min, final double max) {
	final int w = imp.getWidth();
	final int h = imp.getHeight();
	final int d = imp.getStackSize();
	final ImageStack sourceStack = imp.getImageStack();
	final ImageStack binaryStack = new ImageStack(w, h);
	for (int s = 1; s <= d; s++) {
		final ImageProcessor sliceIp = sourceStack.getProcessor(s);
		final ByteProcessor binaryIp = new ByteProcessor(w, h);
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (sliceIp.get(x, y) >= min && sliceIp.get(x, y) <= max) {
					binaryIp.set(x, y, 255);
				} else {
					binaryIp.set(x, y, 0);
				}
			}
		}
		binaryStack.addSlice(sourceStack.getSliceLabel(s), binaryIp);
	}
	final ImagePlus binaryImp = new ImagePlus("binaryImp", binaryStack);
	binaryImp.setCalibration(imp.getCalibration());
	return binaryImp;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:25,代码来源:SliceGeometry.java

示例10: binaryNoise

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Creates an ImagePlus with black (0x00) &amp; white (0xFF) noise
 *
 * @param width width of the image.
 * @param height height of the image.
 * @param depth depth of the image.
 * @param ratio Probability that pixel P(x is black)
 * @param generator A random generator for the noise. Using a generator with
 *          predetermined {@link Random#Random(long)} seed} makes the result
 *          of this method repeatable
 * @return an image with binary noise.
 */
public static ImagePlus binaryNoise(final int width, final int height, final int depth, final double ratio,
									final Random generator) {
	final int npixels = width * height;
	final ImageStack stack = new ImageStack(width, height);
	for (int i = 0; i < depth; i++) {
		final ByteProcessor bp = new ByteProcessor(width, height);
		for (int index = 0; index < npixels; index++) {
			final double random = generator.nextDouble();
			if (random > ratio)
				bp.set(index, 255);
		}
		stack.addSlice(bp);
	}
	final ImagePlus imp = new ImagePlus("binary-noise", stack);
	return imp;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:29,代码来源:TestDataMaker.java

示例11: removeWeakPixels

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static void removeWeakPixels(ByteProcessor bp) {
	int w = bp.getWidth();
	int h = bp.getHeight();
	for (int y = 1; y < h-1; y++) {
		for (int x = 1; x < w-1; x++) {
			// Check if this is a nonzero pixel
			if (bp.get(x, y) == 0)
				continue;
			// Check nonzero neighbours
			if ((bp.get(x-1, y) == 0 && bp.get(x+1, y) == 0) ||
					(bp.get(x-1, y-1) == 0 && bp.get(x+1, y+1) == 0) ||
					(bp.get(x, y-1) == 0 && bp.get(x, y+1) == 0) ||
					(bp.get(x-1, y+1) == 0 && bp.get(x+1, y-1) == 0)) {
				// If we have 2 zero neighbours, in any direction, break the connection
				bp.set(x, y, 0);
			}
				
		}			
	}
}
 
开发者ID:qupath,项目名称:qupath,代码行数:21,代码来源:ROILabeling.java

示例12: fillHoles

import ij.process.ByteProcessor; //导入方法依赖的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

示例13: getThreshold

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor getThreshold(ByteProcessor I) {
	FloatProcessor mean = (FloatProcessor) I.convertToFloat();
	FloatProcessor var = (FloatProcessor) mean.duplicate();
	
	RankFilters rf = new RankFilters();
	rf.rank(mean, params.radius, RankFilters.MEAN);
	Imean = mean;
	
	rf.rank(var, params.radius, RankFilters.VARIANCE);
	var.sqrt();
	Isigma = var;
	
	int width = I.getWidth();
	int height = I.getHeight();
	final double kappa = params.kappa;
	final double sigmaMax = params.sigmaMax;
	final boolean darkBg = (params.bgMode == BackgroundMode.DARK);
	
	ByteProcessor Q = new ByteProcessor(width, height);
	for (int v = 0; v < height; v++) {
		for (int u = 0; u < width; u++) {
			final double sigma = Isigma.getf(u, v);
			final double mu = Imean.getf(u, v);
			final double diff = kappa * (sigma / sigmaMax - 1);
			int q = (int) Math.rint((darkBg) ? mu * (1 - diff) : mu	* (1 + diff));
			if (q < 0)
				q = 0;
			if (q > 255)
				q = 255;
			Q.set(u, v, q);
		}
	}
	return Q;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:36,代码来源:SauvolaThresholder.java

示例14: getThreshold

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public ByteProcessor getThreshold(ByteProcessor I) {
	final int M = I.getWidth();
	final int N = I.getHeight();
	ByteProcessor Imin = (ByteProcessor) I.duplicate();
	ByteProcessor Imax = (ByteProcessor) I.duplicate();

	RankFilters rf = new RankFilters();
	rf.rank(Imin, params.radius, RankFilters.MIN);
	rf.rank(Imax, params.radius, RankFilters.MAX);

	int q = (params.bgMode == BackgroundMode.DARK) ? 256 : 0;
	ByteProcessor Q = new ByteProcessor(M, N);

	for (int v = 0; v < N; v++) {
		for (int u = 0; u < M; u++) {
			int gMin = Imin.get(u, v);
			int gMax = Imax.get(u, v);
			int c = gMax - gMin;
			if (c >= params.cmin)
				Q.set(u, v, (gMin + gMax) / 2);
			else
				Q.set(u, v, q);
		}
	}
	return Q;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:28,代码来源:BernsenThresholder.java

示例15: threshold

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public void threshold(ByteProcessor bp, ByteProcessor Q) {
	final int w = bp.getWidth();
	final int h = bp.getHeight();
	for (int v = 0; v < h; v++) {
		for (int u = 0; u < w; u++) {
			int p = bp.get(u, v);
			int q = Q.get(u, v);
			bp.set(u, v, (p <= q) ? 0 : 255);
		}
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:12,代码来源:AdaptiveThresholder.java


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