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


Java ByteProcessor.getWidth方法代码示例

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


在下文中一共展示了ByteProcessor.getWidth方法的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: makeMeanAndVariance

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
protected void makeMeanAndVariance(ByteProcessor I, Parameters params) {
	int width = I.getWidth();
	int height = I.getHeight();
	Imean =  new FloatProcessor(width, height);
	Isigma =  new FloatProcessor(width, height);
	final int radius = params.radius;
	final int n = (radius + 1 + radius) * (radius + 1 + radius);

	for (int v = 0; v < height; v++) {
		for (int u = 0; u < width; u++) {
			long A = 0;	// sum of image values in support region
			long B = 0;	// sum of squared image values in support region
			for (int j = -radius; j <= radius; j++) {
				for (int i = -radius; i <= radius; i++) {
					int p = getPaddedPixel(I, u + i, v + j); // this is slow!
					A = A + p;
					B = B + p * p;
				}
			}
			Imean.setf(u, v, (float) A / n);
			Isigma.setf(u, v, (float) Math.sqrt((B - (double) (A * A) / n) / n));
		}
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:26,代码来源:NiblackThresholder.java

示例3: dump

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Print out a ByteProcessor.
 *
 * @param title a title for the print
 * @param buf   the input buffer
 */
public static void dump (String title,
                         ByteProcessor buf)
{
    final int width = buf.getWidth();
    final int height = buf.getHeight();

    if (title != null) {
        System.out.println(title);
    }

    final String yFormat = printAbscissae(width, height, 4);

    for (int y = 0; y < height; y++) {
        System.out.printf(yFormat, y);

        for (int x = 0; x < width; x++) {
            System.out.printf("%4d", buf.get(x, y));
        }

        System.out.println();
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:29,代码来源:TableUtil.java

示例4: getForeCount

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Count the number of foreground pixels in the provided image.
 *
 * @param filter the binary image
 * @return the number of foreground pixels
 */
private int getForeCount (ByteProcessor filter)
{
    final int width = filter.getWidth();
    final int height = filter.getHeight();
    int count = 0;

    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            if (filter.get(x, y) == 0) {
                count++;
            }
        }
    }

    return count;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:23,代码来源:SheetDiff.java

示例5: toGlyph

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Build a (fixed) glyph, based on current content of this section compound.
 *
 * @param group targeted group, perhaps null
 * @return a glyph made of compound pixels
 */
public Glyph toGlyph (Group group)
{
    // Fill buffer with section pixels
    final ByteProcessor buffer = toBuffer();

    // Allocate and populate properly oriented run table
    final RunTableFactory factory = new RunTableFactory(
            (buffer.getWidth() > buffer.getHeight()) ? HORIZONTAL : VERTICAL,
            null);
    final RunTable runTable = factory.createTable(buffer);

    // Allocate glyph with proper offset
    final Glyph glyph = new BasicGlyph(bounds.x, bounds.y, runTable);
    glyph.addGroup(group);

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

示例6: 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

示例7: 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

示例8: 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

示例9: toShape

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Convert ImageJ's Roi to Java 3D Shape representation.
 *
 * @param roi source roi.
 * @return translated to Shape.
 */
public static Shape toShape(final Roi roi) {
    final Shape result;
    if (roi instanceof PointRoi) {
        final ByteProcessor mask = (ByteProcessor) roi.getMask();
        final byte[] maskPixels = (byte[]) mask.getPixels();
        final Rectangle maskBounds = roi.getBounds();
        final int maskWidth = mask.getWidth();
        final int maskHeight = mask.getHeight();
        final Area area = new Area();
        for (int y = 0; y < maskHeight; y++) {
            final int yOffset = y * maskWidth;
            for (int x = 0; x < maskWidth; x++) {
                if (maskPixels[x + yOffset] != 0) {
                    area.add(new Area(new Rectangle(x + maskBounds.x, y + maskBounds.y, 1, 1)));
                }
            }
        }
        result = area;
    } else {
        result = makeShapeFromArray(new ShapeRoi(roi).getShapeAsArray());
    }

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

示例10: 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

示例11: 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

示例12: 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

示例13: getPaddedPixel

import ij.process.ByteProcessor; //导入方法依赖的package包/类
protected int getPaddedPixel(ByteProcessor bp, int u, int v) {
	final int w = bp.getWidth();
	final int h = bp.getHeight();
	if (u < 0)
		u = 0;
	else if (u >= w)
		u = w - 1;
	if (v < 0)
		v = 0;
	else if (v >= h)
		v = h - 1;
	return bp.get(u, v);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:14,代码来源:AdaptiveThresholder.java

示例14: getLine

import ij.process.ByteProcessor; //导入方法依赖的package包/类
protected double[] getLine(ByteProcessor bp, int v) {
	double[] line = new double[bp.getWidth()];
	for (int u = 0; u < line.length; u++) {
		line[u] = bp.get(u, v);
	}
	return line;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:8,代码来源:AdaptiveThresholder.java

示例15: getMatch

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public float[][] getMatch(ByteProcessor R) {
	final int MR = R.getWidth();
	final int NR = R.getHeight();
	final int[][] Ra = R.getIntArray();
	float[][] Q = new float[MI - MR + 1][NI - NR + 1];
	for (int r = 0; r <= MI - MR; r++) {
		for (int s = 0; s <= NI - NR; s++) {
			float q = getMatchValue(Ra, r, s);
			Q[r][s] = q;
		}	
	}	
	return Q;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:14,代码来源:ChamferMatcher.java


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