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


Java ByteProcessor.setValue方法代码示例

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


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

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

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

import ij.process.ByteProcessor; //导入方法依赖的package包/类
public static void measureMembrane(PathObject po, ImageProcessor ip, String ipName, Calibration cal, double downsampleFactor) {
		Roi roi = ROIConverterIJ.convertToIJRoi(po.getROI(), cal, downsampleFactor);
		Rectangle bounds = roi.getBounds();
		ByteProcessor bp = new ByteProcessor(bounds.width, bounds.height);
		roi.setLocation(0, 0);
		bp.setValue(255);
		bp.draw(roi);
		double sum = 0;
		int count = 0;
		double min = Double.POSITIVE_INFINITY;
		double max = Double.NEGATIVE_INFINITY;
		for (int y = 0; y < bounds.height; y++) {
			for (int x = 0; x < bounds.width; x++) {
				if (bp.get(x, y) != 0) {
					double val = ip.getf(x+bounds.x, y+bounds.y);
					sum += val;
					count++;
					if (val > max)
						max = val;
					if (val < min)
						min = val;
				}
					
			}			
		}
		roi.setLocation(bounds.x, bounds.y);
		po.getMeasurementList().addMeasurement("Membrane mean"+SPLIT_CHAR+" "+ipName, sum/count);
//		po.addMeasurement("Membrane min"+SPLIT_CHAR+" "+ipName, min);
//		po.addMeasurement("Membrane max"+SPLIT_CHAR+" "+ipName, max);
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:31,代码来源:ObjectMeasurements.java


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