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


Java ByteProcessor类代码示例

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


ByteProcessor类属于ij.process包,在下文中一共展示了ByteProcessor类的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: showFilter

import ij.process.ByteProcessor; //导入依赖的package包/类
public void showFilter(int[][] filter, String title){
	int w = filter[0].length;
	int h = filter.length;
	ImageProcessor ip = new ByteProcessor(w,h);
	for (int v = 0; v < h; v++) {
		for (int u = 0; u < w; u++) {
			if (filter[v][u] == 1)
				ip.putPixel(u, v, 255);
			else
				ip.putPixel(u, v, 0);
		}
	}
	ip.invertLut();
	ImagePlus win = new ImagePlus(title,ip);
	win.show();
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:17,代码来源:BinMorpher.java

示例4: filter

import ij.process.ByteProcessor; //导入依赖的package包/类
public void filter(ImageProcessor ip) {
	ColorProcessor I = (ColorProcessor) ip;
	
	// extract color channels as individual ByteProcessor images:
	ByteProcessor Ir = new ByteProcessor(M, N);
	ByteProcessor Ig = new ByteProcessor(M, N);
	ByteProcessor Ib = new ByteProcessor(M, N);
	byte[] pR = (byte[]) Ir.getPixels();
	byte[] pG = (byte[]) Ig.getPixels();
	byte[] pB = (byte[]) Ib.getPixels();
	I.getRGB(pR, pG, pB);
	
	FilterScalar fm = new FilterScalar();
	fm.filter(Ir);
	fm.filter(Ig);
	fm.filter(Ib);
	
	// copy back to color image
	I.setRGB(pR, pG, pB);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:21,代码来源:PeronaMalikFilter.java

示例5: process

import ij.process.ByteProcessor; //导入依赖的package包/类
private void process(ImageProcessor ip) {
	ByteProcessor check = new ByteProcessor(M, N);
	if (params.showProgress) IJ.showStatus("filling accumulator ...");
	for (int v = 0; v < N; v++) {
		if (params.showProgress) IJ.showProgress(v, N);
		for (int u = 0; u < M; u++) {
			if ((0xFFFFFF & ip.get(u, v)) != 0) { // this is a foreground (edge) pixel - use ImageAccessor??
				doOnePoint(u, v);
				check.putPixel(u, v, 128);
			}
		}
	}
	if (params.showProgress) 
		IJ.showProgress(1, 1);
	if (params.showCheckImage)
		(new ImagePlus("Check", check)).show();
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:18,代码来源:HoughTransformLinesPosRadius.java

示例6: detectAndTraceEdges

import ij.process.ByteProcessor; //导入依赖的package包/类
private void detectAndTraceEdges() {
	if (Enms == null) {
		nonMaxSuppression();
	}
	Ebin = new ByteProcessor(M, N);
	int color = 255;
	traceList = new LinkedList<List<Point>>();
	for (int v = 0; v < N; v++) {
		for (int u = 0; u < M; u++) {
			if (Enms.getf(u, v) >= params.hiThr && Ebin.get(u, v) == 0) { // unmarked edge point
				List<Point> trace = traceAndThreshold(u, v, (float) params.loThr, color);
				traceList.add(trace);
			}
		}
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:17,代码来源:CannyEdgeDetector.java

示例7: quantize

import ij.process.ByteProcessor; //导入依赖的package包/类
/**
 * Performs color quantization on the given full-color RGB image
 * and creates an indexed color image.
 * 
 * @param cp The original full-color RGB image.
 * @return The quantized (indexed color) image.
 */
public ByteProcessor quantize(ColorProcessor cp) {
	int[][] colormap = this.getColorMap();
	if (colormap.length > 256) 
		throw new Error("cannot index to more than 256 colors");
	int w = cp.getWidth();
	int h = cp.getHeight();
	int[]  rgbPixels = (int[]) cp.getPixels();
	byte[] idxPixels = new byte[rgbPixels.length];

	for (int i = 0; i < rgbPixels.length; i++) {
		idxPixels[i] = (byte) this.findColorIndex(rgbPixels[i]);
	}

	IndexColorModel idxCm = makeIndexColorModel(colormap);
	return new ByteProcessor(w, h, idxPixels, idxCm);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:24,代码来源:ColorQuantizer.java

示例8: Rgb

import ij.process.ByteProcessor; //导入依赖的package包/类
public Rgb(ColorProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) {
	super(ip, obs, ipm);
	this.ip = ip;
	this.pixels = (int[]) this.ip.getPixels();
	
	int width  = ip.getWidth();
	int height = ip.getHeight();
	ByteProcessor rp = new ByteProcessor(width, height);
	ByteProcessor gp = new ByteProcessor(width, height);
	ByteProcessor bp = new ByteProcessor(width, height);
	byte[] rpix = (byte[]) rp.getPixels();
	byte[] gpix = (byte[]) gp.getPixels();
	byte[] bpix = (byte[]) bp.getPixels();
	ip.getRGB(rpix, gpix, bpix);	// fill byte arrays
	rAcc = new ImageAccessor.Byte(rp, obs, ipm);
	gAcc = new ImageAccessor.Byte(gp, obs, ipm);
	bAcc = new ImageAccessor.Byte(bp, obs, ipm);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:19,代码来源:ImageAccessor.java

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

示例10: testBlobs

import ij.process.ByteProcessor; //导入依赖的package包/类
public void testBlobs() throws Exception {
    // Load test image
    final ByteProcessor image = (ByteProcessor) IOUtils.openImage(BLOBS_FILE_NAME).getProcessor();
    final Point[][] seeds = {
            {new Point(107, 144)}, // Background
            {new Point(91, 159)},  // Blob 1
            {new Point(119, 143)}, // Blob 2
    };

    // Setup region growing
    final SRG srg = new SRG();
    srg.setImage(image);
    srg.setSeeds(SRG.toSeedImage(seeds, image.getWidth(), image.getHeight()));
    srg.setNumberOfAnimationFrames(50);

    // Run growing
    srg.run();

    final ByteProcessor regionMask = srg.getRegionMarkers();
    final ImagePlus imp = new ImagePlus("Region Mask", regionMask);

    IOUtils.forceMkDirs(new File(OUTPUT_DIR));

    IOUtils.saveAsTiff(imp, new File(OUTPUT_DIR, "srg_test_output.tif"));
    IOUtils.saveAsTiff(imp, new File(OUTPUT_DIR, "srg_test_animation.tif"));
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:27,代码来源:SRGTest.java

示例11: getSections

import ij.process.ByteProcessor; //导入依赖的package包/类
/**
 * Build all the system sections that could be part of OCR'ed items.
 *
 * @param buffer the pixel buffer used by OCR
 * @param lines  the text lines kept
 * @return the collection of candidate sections
 */
private List<Section> getSections (ByteProcessor buffer,
                                   List<TextLine> lines)
{
    SectionFactory factory = new SectionFactory(VERTICAL, JunctionRatioPolicy.DEFAULT);
    List<Section> allSections = new ArrayList<Section>();

    for (TextLine line : lines) {
        for (TextWord word : line.getWords()) {
            Rectangle roi = word.getBounds();
            List<Section> wordSections = factory.createSections(buffer, roi);
            allSections.addAll(wordSections);
        }
    }

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

示例12: gaussianFiltered

import ij.process.ByteProcessor; //导入依赖的package包/类
public ByteProcessor gaussianFiltered (ByteProcessor src)
{
    StopWatch watch = new StopWatch("Gaussian");

    try {
        watch.start("Filter " + src.getWidth() + "x" + src.getHeight());

        final int radius = constants.gaussianRadius.getValue();
        logger.debug("Image blurred with gaussian kernel radius: {}", radius);

        GaussianGrayFilter gaussianFilter = new GaussianGrayFilter(radius);

        return gaussianFilter.filter(src);
    } finally {
        if (constants.printWatch.isSet()) {
            watch.print();
        }
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:20,代码来源:Picture.java

示例13: getImage

import ij.process.ByteProcessor; //导入依赖的package包/类
/**
 * Report the sheet image, or a sub-image of it if rectangle area is specified.
 * <p>
 * We use the initial image if it is still available.
 * Otherwise we use the binary source.
 *
 * @param rect rectangular area desired, null for whole image
 * @return the (sub) image
 */
public BufferedImage getImage (Rectangle rect)
{
    BufferedImage img = initialImage;

    if (img == null) {
        ByteProcessor buffer = getSource(SourceKey.BINARY);
        img = buffer.getBufferedImage();
    }

    if (rect == null) {
        return img;
    } else {
        return img.getSubimage(rect.x, rect.y, rect.width, rect.height);
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:25,代码来源:Picture.java

示例14: convolve

import ij.process.ByteProcessor; //导入依赖的package包/类
/** Convolves <code>ip</code> with a kernel of width <code>kw</code> and
	height <code>kh</code>. Returns false if the user cancels the operation. */
public boolean convolve(ImageProcessor ip, float[] kernel, int kw, int kh) {
	if (canceled || kw*kh!=kernel.length) return false;
	if ((kw&1)!=1 || (kh&1)!=1)
		throw new IllegalArgumentException("Kernel width or height not odd ("+kw+"x"+kh+")");
	boolean notFloat = !(ip instanceof FloatProcessor);
	ImageProcessor ip2 = ip;
	if (notFloat) {
		if (ip2 instanceof ColorProcessor) 
			throw new IllegalArgumentException("RGB images not supported");
		ip2 = ip2.convertToFloat();
	}
	if (kw==1 || kh==1)
		convolveFloat1D((FloatProcessor)ip2, kernel, kw, kh, normalize?getScale(kernel):1.0);
	else
		convolveFloat(ip2, kernel, kw, kh);
	if (notFloat) {
		if (ip instanceof ByteProcessor)
			ip2 = ip2.convertToByte(false);
		else
			ip2 = ip2.convertToShort(false);
		ip.setPixels(ip2.getPixels());
	}
	return !canceled;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:SME_ENS_Convolver.java

示例15: actionSeedImage

import ij.process.ByteProcessor; //导入依赖的package包/类
public void actionSeedImage() {
    final ImagePlus imp = UIUtils.getImage();
    if (imp == null) {
        return;
    }

    final List<Region> regions = multiRegionManagerModel.getRegions();
    if (regions.size() < 1) {
        IJ.error(CAPTION, "Cannot create seed image, at least one regions required.");
        return;
    }

    final ByteProcessor seeds = createSeedImage(regions, imp.getWidth(), imp.getHeight());
    if (seeds == null) {
        return;
    }

    seeds.setMinAndMax(0, regions.size());
    new ImagePlus("Seeds", seeds).show();
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:21,代码来源:RegionGrowingModel.java


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