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


Java ByteProcessor.fill方法代码示例

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


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

示例1: eraseHeaderAreas

import ij.process.ByteProcessor; //导入方法依赖的package包/类
private void eraseHeaderAreas (ByteProcessor buffer)
{
    final int dmzDyMargin = sheet.getScale().toPixels(constants.staffVerticalMargin);

    buffer.setValue(255);

    for (SystemInfo system : sheet.getSystems()) {
        Staff firstStaff = system.getFirstStaff();
        Staff lastStaff = system.getLastStaff();
        int start = system.getBounds().x;
        int stop = firstStaff.getHeaderStop();
        int top = firstStaff.getFirstLine().yAt(stop) - dmzDyMargin;
        int bot = lastStaff.getLastLine().yAt(stop) + dmzDyMargin;

        buffer.setRoi(start, top, stop - start + 1, bot - top + 1);
        buffer.fill();
        buffer.resetRoi();
    }

    buffer.setValue(0);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:22,代码来源:SpotsBuilder.java

示例2: labelsToFilledROIs

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Convert a labelled image into a list of PolygonRois by tracing.
 * Note that labels are assumed not to contain any holes or nested ROIs; ROIs produced by this command will not contain holes.
 * Some entries in the resulting array may be null if this is not the case, or if not all labels are found.
 * Otherwise, pixels with the integer label L will belong to the Roi in the output array at entry L-1
 * 
 * @param ipLabels
 * @param n - maximum number of labels
 * @return
 */
public static PolygonRoi[] labelsToFilledROIs(ImageProcessor ipLabels, int n) {
	PolygonRoi[] rois = new PolygonRoi[n];
	int w = ipLabels.getWidth();
	int h = ipLabels.getHeight();
	ByteProcessor bpCompleted = new ByteProcessor(w, h);
	bpCompleted.setValue(255);
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (bpCompleted.get(x, y) != 0)
				continue;
			float val = ipLabels.getf(x, y);
			if (val > 0 && val <= n) {
				Wand wand = new Wand(ipLabels);
				wand.autoOutline(x, y, val, val, Wand.EIGHT_CONNECTED);
				PolygonRoi roi = wandToRoi(wand);
				rois[(int)val-1] = roi;
				bpCompleted.fill(roi);
			}
		}
	}
	return rois;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:33,代码来源:ROILabeling.java

示例3: labelsToFilledRoiList

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Convert a labelled image into a list of PolygonRois by tracing.
 * 
 * Unlike labelsToFilledROIs, the order in which ROIs are returned is arbitrary.
 * 
 * Also, the multiple Rois may be created for the same label, if unconnected regions are used.
 * 
 * @param ipLabels
 * @param n - maximum number of labels
 * @return
 */
public static List<PolygonRoi> labelsToFilledRoiList(final ImageProcessor ipLabels, final boolean conn8) {
	List<PolygonRoi> rois = new ArrayList<>();
	int w = ipLabels.getWidth();
	int h = ipLabels.getHeight();
	ByteProcessor bpCompleted = new ByteProcessor(w, h);
	bpCompleted.setValue(255);
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (bpCompleted.get(x, y) != 0)
				continue;
			float val = ipLabels.getf(x, y);
			if (val > 0) {
				Wand wand = new Wand(ipLabels);
				wand.autoOutline(x, y, val, val, conn8 ? Wand.EIGHT_CONNECTED : Wand.FOUR_CONNECTED);
				PolygonRoi roi = wandToRoi(wand);
				rois.add(roi);
				bpCompleted.fill(roi);
			}
		}
	}
	return rois;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:34,代码来源:ROILabeling.java

示例4: fillOutside

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
	 * Fill in a region outside a specified ROI
	 * @param ip
	 * @param roi
	 */
	public static void fillOutside(ImageProcessor ip, Roi roi, double value) {
		// Check we don't have a full rectangle
		if (roi.getType() == Roi.RECTANGLE && roi.getBounds().equals(new Rectangle(0, 0, ip.getWidth(), ip.getHeight())))
			return;
//		if (roi instanceof ShapeRoi) {
			// Appears to be a bug with ShapeRois so that filling outside can fail using ImageJ's own code
			ByteProcessor bpMask = new ByteProcessor(ip.getWidth(), ip.getHeight());
			bpMask.setValue(1);
			bpMask.fill(roi);
			if (value == 0)
				ip.copyBits(bpMask, 0, 0, Blitter.MULTIPLY);
			else {
				float floatValue = (float)value;
				byte[] px = (byte[])bpMask.getPixels();
				for (int i = 0; i < px.length; i++) {
					if (px[i] == (byte)0)
						ip.setf(i, floatValue);
				}
			}
//		} else {
//			ip.setValue(value);
//			ip.fillOutside(roi);
//		}
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:30,代码来源:ROILabeling.java

示例5: run

import ij.process.ByteProcessor; //导入方法依赖的package包/类
@Override
public void run(final ImageProcessor ip) {

    final GenericDialog gd = new GenericDialog(TITLE);
    gd.addMessage("Set pixels in current ROI to a specified value [0 to 255].");
    gd.addNumericField("Value:", value.get(), 0);

    gd.showDialog();

    if (gd.wasCanceled()) {
        return;
    }

    value.set(Math.max(0, Math.min(255, (int) Math.round(gd.getNextNumber()))));
    IJ.showStatus("Setting ROI pixels to " + value);

    final ByteProcessor bp = (ByteProcessor) ip;
    bp.setColor(value.get());
    bp.fill();
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:21,代码来源:SetPixelsPlugin.java

示例6: labelsToConnectedROIs

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
 * Create ROIs from labels in an image.
 * 
 * This differs from labelsToConnectedROIs in that the ROIs created may be
 * disconnected and contain holes.
 * 
 * @param ipLabels
 * @param n
 * @return
 */
public static Roi[] labelsToConnectedROIs(ImageProcessor ipLabels, int n) {
	Roi[] rois = new Roi[n];
	int w = ipLabels.getWidth();
	int h = ipLabels.getHeight();
	ByteProcessor bpCompleted = new ByteProcessor(w, h);
	bpCompleted.setValue(255);
	ThresholdToSelection tts = new ThresholdToSelection();
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (bpCompleted.get(x, y) != 0)
				continue;
			float val = ipLabels.getf(x, y);
			if (val > 0 && val <= n) {
				Wand wand = new Wand(ipLabels);
				ipLabels.resetThreshold();
				wand.autoOutline(x, y, val, val, Wand.EIGHT_CONNECTED);
				Roi roi = wandToRoi(wand);
				
				// Check if ROI contains holes, and create if necessary
				ipLabels.setRoi(roi);
				ImageStatistics stats = ipLabels.getStatistics();
				if (stats.max != stats.min || rois[(int)val-1] != null) {
					ipLabels.setThreshold(val-0.25, val+0.25, ImageProcessor.NO_LUT_UPDATE);
					roi = tts.convert(ipLabels);
				}
				
				rois[(int)val-1] = roi;
				bpCompleted.fill(roi);
			}
		}
	}
	return rois;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:44,代码来源:ROILabeling.java

示例7: getFilledPolygonROIsFromLabels

import ij.process.ByteProcessor; //导入方法依赖的package包/类
/**
	 * Get filled Polygon ROIs using distinct labels, creating a map between labels and ROIs.
	 * <p>
	 * Note that discontinuous ROIs are not supported; if labelled regions are discontinuous,
	 * then ROIs detected earlier will be discarded from the map.
	 * 
	 * @param ip
	 * @param wandMode
	 * @return
	 */
	public static Map<Float, PolygonRoi> getFilledPolygonROIsFromLabels(ImageProcessor ip, int wandMode) {
//		Wand wand = new Wand(ip);
		double threshLower = ip.getMinThreshold();
		if (threshLower == ImageProcessor.NO_THRESHOLD)
			threshLower = Double.NEGATIVE_INFINITY;
		double threshHigher = ip.getMaxThreshold();
		if (threshHigher == ImageProcessor.NO_THRESHOLD)
			threshHigher = Double.POSITIVE_INFINITY;
		int w = ip.getWidth();
		int h = ip.getHeight();
//		List<PolygonRoi> rois = new ArrayList<>();
		ByteProcessor bpCompleted = new ByteProcessor(w, h);
		bpCompleted.setValue(255);
		TreeMap<Float, PolygonRoi> map = new TreeMap<>();
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (bpCompleted.get(x, y) != 0)
					continue;
				float val = ip.getf(x, y);
				if (val >= threshLower && val <= threshHigher) {
					Wand wand = new Wand(ip);
					wand.autoOutline(x, y, threshLower, threshHigher, wandMode);
					PolygonRoi roi = wandToRoi(wand);
//					rois.add(roi);
					Float key = val;
					if (map.containsKey(key))
						logger.warn("Polygon ROI is being inserted twice into map for the same key {}", key);
					map.put(val, roi);
					bpCompleted.fill(roi);
				}
			}
		}
		return map;
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:45,代码来源:ROILabeling.java

示例8: getFilledPolygonROIs

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static List<PolygonRoi> getFilledPolygonROIs(ImageProcessor ip, int wandMode) {
//		Wand wand = new Wand(ip);
		double threshLower = ip.getMinThreshold();
		if (threshLower == ImageProcessor.NO_THRESHOLD)
			threshLower = Double.NEGATIVE_INFINITY;
		double threshHigher = ip.getMaxThreshold();
		if (threshHigher == ImageProcessor.NO_THRESHOLD)
			threshHigher = Double.POSITIVE_INFINITY;
		int w = ip.getWidth();
		int h = ip.getHeight();
		List<PolygonRoi> rois = new ArrayList<>();
		ByteProcessor bpCompleted = new ByteProcessor(w, h);
		bpCompleted.setValue(255);
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (bpCompleted.get(x, y) != 0)
					continue;
				float val = ip.getf(x, y);
				if (val >= threshLower && val <= threshHigher) {
					Wand wand = new Wand(ip);
					wand.autoOutline(x, y, threshLower, threshHigher, wandMode);
					PolygonRoi roi = wandToRoi(wand);
					rois.add(roi);
					bpCompleted.fill(roi);
				}
			}
		}
		return rois;
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:30,代码来源:ROILabeling.java

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

示例10: testRampWithMask

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public void testRampWithMask() throws Exception {
    // Load test image
    final ByteProcessor image = (ByteProcessor) IOUtils.openImage(RAMP_FILE_NAME).getProcessor();

    final Point[][] seeds = {
            {new Point(90, 100)}, // dark
            {new Point(110, 100)} // bright
    };

    final ByteProcessor mask = new ByteProcessor(image.getWidth(), image.getHeight());
    mask.setRoi(50, 50, 100, 100);
    mask.setColor(255);
    mask.fill();

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

    // Run growing
    srg.run();

    final ByteProcessor regionMarkers = srg.getRegionMarkers();
    ImagePlus imp1 = new ImagePlus("Region Markers", regionMarkers);
    new File(OUTPUT_DIR).mkdirs();
    IOUtils.saveAsTiff(imp1, new File(OUTPUT_DIR, "srg_ramp_with_mask_test_output.tif"));
    IOUtils.saveAsTiff(srg.getAnimationStack(), new File(OUTPUT_DIR, "srg_ramp_with_mask_test_animation.tif"));

    // Mask
    assertEquals(0, regionMarkers.get(10, 10));

    assertEquals(0, regionMarkers.get(190, 190));

    // Region 1
    assertEquals(1, regionMarkers.get(60, 60));

    // Region 2
    assertEquals(2, regionMarkers.get(120, 60));
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:42,代码来源:SRGTest.java


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