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


Java ByteProcessor.copyBits方法代码示例

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


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

示例1: getParts

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Retrieve all glyph instances that could be part of clef.
 *
 * @param isFirstPass true for first pass
 * @return clef possible parts
 */
private List<Glyph> getParts (boolean isFirstPass)
{
    final Rectangle rect = isFirstPass ? outerRect : innerRect;

    // Grab pixels out of staff-free source
    ByteProcessor source = sheet.getPicture().getSource(Picture.SourceKey.NO_STAFF);
    ByteProcessor buf = new ByteProcessor(rect.width, rect.height);
    buf.copyBits(source, -rect.x, -rect.y, Blitter.COPY);

    // Extract parts
    RunTable runTable = new RunTableFactory(VERTICAL).createTable(buf);
    List<Glyph> parts = GlyphFactory.buildGlyphs(runTable, rect.getLocation());

    // Keep only interesting parts
    purgeParts(parts, isFirstPass);

    system.registerGlyphs(parts, Group.CLEF_PART);
    logger.debug("{} parts: {}", this, parts.size());

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

示例2: dilate

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private void dilate(ByteProcessor ip, int[][] H) {
	if (H == null) {
		IJ.error("no structuring element");
		return;
	}

	//assume that the hot spot of se is at its center (ic,jc)
	int ic = (H[0].length - 1) / 2;
	int jc = (H.length - 1) / 2;
	int N = H.length * H[0].length;
	
	ImageProcessor tmp = ip.createProcessor(ip.getWidth(), ip.getHeight());
	
	int k = 0;
	IJ.showProgress(k, N);
	for (int j = 0; j < H.length; j++) {
		for (int i = 0; i < H[j].length; i++) {
			if (H[j][i] > 0) { // this element is set
				// copy image into position (u-ch,v-cv)
				tmp.copyBits(ip, i - ic, j - jc, Blitter.MAX);
			}
			IJ.showProgress(k++, N);
		}
	}
	ip.copyBits(tmp, 0, 0, Blitter.COPY);
	
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:28,代码来源:BinaryMorphologyFilter.java

示例3: outline

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public void outline(ByteProcessor ip) {
	int[][] H = { 
			{ 0, 1, 0 }, 
			{ 1, 1, 1 }, 
			{ 0, 1, 0 } };
	ByteProcessor foreground = (ByteProcessor) ip.duplicate();
	erode(foreground, H);
	ip.copyBits(foreground, 0, 0, Blitter.DIFFERENCE);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:10,代码来源:BinaryMorphologyFilter.java

示例4: getBuffer

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Compute the scaled buffer for the provided glyph, using related staff interline
 * value.
 *
 * @param glyph     the source glyph
 * @param interline the related staff interline
 * @return the computed buffer using 0 for black (foreground) and 255 for white (background)
 */
public static ByteProcessor getBuffer (Glyph glyph,
                                       int interline)
{
    final RunTable runTable = glyph.getRunTable();
    final ByteProcessor glyphBuffer = runTable.getBuffer();
    final double scale = (double) INTERLINE / interline;

    // Build scaled buffer, filled by (scaled) glyph
    final int scaledWidth = (int) Math.ceil(runTable.getWidth() * scale);
    final int scaledHeight = (int) Math.ceil(runTable.getHeight() * scale);
    final ByteProcessor scaledBuffer = (ByteProcessor) glyphBuffer.resize(
            scaledWidth,
            scaledHeight,
            true); // True => use averaging when down-scaling

    // Copy scaledBuffer into a WIDTH*HEIGHT target buffer centered on glyph centroid
    final Point centroid = glyph.getCentroid();
    final Point center = glyph.getCenter();
    final int dx = centroid.x - center.x; // X shift of centroid WRT center
    final int dy = centroid.y - center.y; // Y shift of centroid WRT center
    final int targetDx = (int) Math.rint(dx * scale); // Scaled x shift
    final int targetDy = (int) Math.rint(dy * scale); // Scaled y shift

    final ByteProcessor buffer = new ByteProcessor(WIDTH, HEIGHT); // Same dim for any symbol
    ByteUtil.raz(buffer); // Correct
    ///ByteUtil.fill(targetBuffer, 100); // Not correct, just meant to visualize limits...

    final int xOffset = ((WIDTH - scaledWidth) / 2) - targetDx;
    final int yOffset = ((HEIGHT - scaledHeight) / 2) - targetDy;
    buffer.copyBits(scaledBuffer, xOffset, yOffset, Blitter.COPY);

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

示例5: getAreaPixels

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Report the pixels buffer for the whole key area
 *
 * @param source pixel source (staff free)
 * @param range  start/stop values for key area
 * @return the buffer of area pixels
 */
public ByteProcessor getAreaPixels (ByteProcessor source,
                                    StaffHeader.Range range)
{
    Rectangle keyRect = new Rectangle(range.getStart(), y, range.getWidth(), height);
    ByteProcessor keyBuffer = new ByteProcessor(keyRect.width, height);
    keyBuffer.copyBits(source, -keyRect.x, -y, Blitter.COPY);

    return keyBuffer;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:17,代码来源:KeyRoi.java

示例6: getParts

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Retrieve all glyph instances that could be part of time sig.
 *
 * @return time sig possible parts
 */
private List<Glyph> getParts (Rectangle rect)
{
    final Sheet sheet = system.getSheet();

    // Grab pixels out of staff-free source
    ByteProcessor source = sheet.getPicture().getSource(Picture.SourceKey.NO_STAFF);
    ByteProcessor buf = new ByteProcessor(rect.width, rect.height);
    buf.copyBits(source, -rect.x, -rect.y, Blitter.COPY);

    // Extract parts
    RunTable runTable = new RunTableFactory(VERTICAL).createTable(buf);
    List<Glyph> parts = GlyphFactory.buildGlyphs(runTable, rect.getLocation());

    // Keep only interesting parts
    purgeParts(parts, rect);

    final GlyphIndex glyphIndex = sheet.getGlyphIndex();

    for (ListIterator<Glyph> li = parts.listIterator(); li.hasNext();) {
        final Glyph part = li.next();
        Glyph glyph = glyphIndex.registerOriginal(part);
        glyph.addGroup(Group.TIME_PART); // For debug?
        system.addFreeGlyph(glyph);
        li.set(glyph);
    }

    return parts;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:34,代码来源:TimeBuilder.java

示例7: clearBoundary

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
	 * Starting from all white pixels (value = 255) on a ROI's boundary,
	 * fill the pixels with black
	 * 
	 * @param bp
	 * @param roi
	 * @param clearValue
	 */
	public static void clearBoundary(ByteProcessor bp, Roi roi, double clearValue) {
		ByteProcessor bpEdgeMask = new ByteProcessor(bp.getWidth(), bp.getHeight());
		bpEdgeMask.setValue(255);
		if (roi == null)
			bpEdgeMask.fill();
		else {
			bpEdgeMask.fill(roi);
		}
		bpEdgeMask.filter(ByteProcessor.MIN);
		bpEdgeMask.invert();
		bpEdgeMask.copyBits(bp, 0, 0, Blitter.AND);
		bpEdgeMask = MorphologicalReconstruction.binaryReconstruction(bpEdgeMask, bp, false);
		bp.copyBits(bpEdgeMask, 0, 0, Blitter.SUBTRACT);
//
//		ImagePlus imp = new ImagePlus("Edge", bp.duplicate());
//		imp.setRoi(roi);
//		imp.show();

//		ByteProcessor bpEdgeMask = new ByteProcessor(bp.getWidth(), bp.getHeight());
//		bpEdgeMask.setValue(255);
//		bpEdgeMask.setLineWidth(2);
//		if (roi == null)
//			bpEdgeMask.draw(new Roi(0, 0, bp.getWidth(), bp.getHeight()));
//		else
//			bpEdgeMask.draw(roi);
//		bpEdgeMask.copyBits(bp, 0, 0, Blitter.AND);
//		bpEdgeMask = MorphologicalReconstruction.binaryReconstruction(bpEdgeMask, bp, false);
//		bp.copyBits(bpEdgeMask, 0, 0, Blitter.SUBTRACT);
//		new ImagePlus("Edge", bp.duplicate()).show();
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:39,代码来源:ROILabeling.java

示例8: getSlicePixels

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Report the pixels buffer for just a slice
 *
 * @param source        pixel source (staff free)
 * @param slice         the current slice
 * @param cropNeighbors true for discarding pixels taken by neighboring slices
 * @return the buffer of slice pixels
 */
public ByteProcessor getSlicePixels (ByteProcessor source,
                                     KeySlice slice,
                                     boolean cropNeighbors)
{
    Rectangle sRect = slice.getRect();
    BufferedImage sImage = new BufferedImage(
            sRect.width,
            sRect.height,
            BufferedImage.TYPE_BYTE_GRAY);
    ByteProcessor sBuffer = new ByteProcessor(sImage);
    sBuffer.copyBits(source, -sRect.x, -sRect.y, Blitter.COPY);

    if (cropNeighbors) {
        // Erase good key items from adjacent slices, if any
        final int idx = indexOf(slice);
        final Integer prevIdx = (idx > 0) ? (idx - 1) : null;
        final Integer nextIdx = (idx < (size() - 1)) ? (idx + 1) : null;
        Graphics2D g = null;

        for (Integer i : new Integer[]{prevIdx, nextIdx}) {
            if (i != null) {
                final KeySlice sl = get(i);

                if (sl.getAlter() != null) {
                    final Glyph glyph = sl.getAlter().getGlyph();

                    if (glyph.getBounds().intersects(sRect)) {
                        if (g == null) {
                            g = sImage.createGraphics();
                            g.setColor(Color.white);
                        }

                        final Point offset = new Point(
                                glyph.getLeft() - sRect.x,
                                glyph.getTop() - sRect.y);
                        logger.debug("Erasing glyph#{} from {}", glyph.getId(), slice);
                        glyph.getRunTable().render(g, offset);
                    }
                }
            }
        }

        if (g != null) {
            g.dispose();
        }
    }

    return sBuffer;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:58,代码来源:KeyRoi.java


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