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


Java PointRoi类代码示例

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


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

示例1: testPointRoiCoordinates

import ij.gui.PointRoi; //导入依赖的package包/类
@Test
public void testPointRoiCoordinates() throws Exception {
	final PointRoi pointRoi = new PointRoi(8, 9);
	pointRoi.setPosition(13);
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(new Roi[] { new Roi(1, 2,
		1, 1), pointRoi, new TextRoi(3, 4, "foo") });

	final List<Vector3d> points = RoiManagerUtil.pointROICoordinates(
		MOCK_ROI_MANAGER);

	assertEquals(1, points.size());
	final Vector3d point = points.get(0);
	assertEquals(pointRoi.getXBase(), point.x, 1e-12);
	assertEquals(pointRoi.getYBase(), point.y, 1e-12);
	assertEquals(pointRoi.getPosition(), point.z, 1e-12);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:RoiManagerUtilTest.java

示例2: convertToPathROI

import ij.gui.PointRoi; //导入依赖的package包/类
/**
	 * Create a ROI from an ImageJ Roi.
	 * 
	 * @param pathROI
	 * @param pathImage
	 * @return
	 */
	public static ROI convertToPathROI(Roi roi, Calibration cal, double downsampleFactor, final int c, final int z, final int t) {
//		if (roi.getType() == Roi.POLYGON || roi.getType() == Roi.TRACED_ROI)
//			return convertToPolygonROI((PolygonRoi)roi, cal, downsampleFactor);
		if (roi.getType() == Roi.RECTANGLE && roi.getCornerDiameter() == 0)
			return getRectangleROI(roi, cal, downsampleFactor, c, z, t);
		if (roi.getType() == Roi.OVAL)
			return convertToEllipseROI(roi, cal, downsampleFactor, c, z, t);
		if (roi instanceof Line)
			return convertToLineROI((Line)roi, cal, downsampleFactor, c, z, t);
		if (roi instanceof PointRoi)
			return convertToPointROI((PolygonRoi)roi, cal, downsampleFactor, c, z, t);
//		if (roi instanceof ShapeRoi)
//			return convertToAreaROI((ShapeRoi)roi, cal, downsampleFactor);
//		// Shape ROIs should be able to handle most eventualities
		if (roi instanceof ShapeRoi)
			return convertToAreaROI((ShapeRoi)roi, cal, downsampleFactor, c, z, t);
		if (roi.isArea())
			return convertToPolygonOrAreaROI(roi, cal, downsampleFactor, c, z, t);
		// TODO: Integrate ROI not supported exception...?
		return null;	
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:29,代码来源:ROIConverterIJ.java

示例3: toShape

import ij.gui.PointRoi; //导入依赖的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

示例4: configure

import ij.gui.PointRoi; //导入依赖的package包/类
public void configure() throws Exception {
	roiman = (RoiManager.getInstance() != null) ? RoiManager.getInstance() : new RoiManager();
	image = IJ.getImage();
	if (image != null){
		if(roiman != null){
			configured = true;
			for (Roi x : roiman.getRoisAsArray()) {
				if (!(x instanceof PointRoi)) {
					configured = false;
					break;
				}
			}
		}
		else
			throw new UnsupportedOperationException("Selected Points not Valid");
	}
	else
		throw new UnsupportedOperationException("No valid image");
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:20,代码来源:PointSelectorWorker.java

示例5: writeOverlay

import ij.gui.PointRoi; //导入依赖的package包/类
/** Write an overlay, if supported */
private void writeOverlay(
        XMLStreamWriter xsw,
        Roi roi) 
        throws SlideSetException {
    if(roi instanceof Line)
        writeLine(xsw, (Line) roi);
    else if(roi instanceof OvalRoi)
        writeOvalRoi(xsw, (OvalRoi) roi);
    else if(roi instanceof PointRoi)
        writePointRoi(xsw, (PointRoi) roi);
    else if(roi instanceof PolygonRoi)
        writePolygonRoi(xsw, (PolygonRoi) roi);
    else if(roi instanceof ShapeRoi)
        writeShapeRoi(xsw, (ShapeRoi) roi);
    else if(roi.getType() == Roi.RECTANGLE)
        writeRectangle(xsw, roi);
    else
        throw new UnsupportedOverlayException(
                "Unsupported ROI type: " 
                + roi.getClass().getName());
}
 
开发者ID:bnanes,项目名称:slideset,代码行数:23,代码来源:IJ1ROIsToSVGFileWriter.java

示例6: writePointRoi

import ij.gui.PointRoi; //导入依赖的package包/类
/** Write a PointRoi */
private void writePointRoi(
        final XMLStreamWriter xsw, 
        final PointRoi roi) 
        throws SlideSetException {
    final FloatPolygon fp = roi.getFloatPolygon();
    try {
        for(int i=0; i<fp.npoints; i++) {
            xsw.writeStartElement("line");
            xsw.writeAttribute("class", "roi PointRoi");
            xsw.writeAttribute("x1", String.valueOf(fp.xpoints[i]));
            xsw.writeAttribute("y1", String.valueOf(fp.ypoints[i]));
            xsw.writeAttribute("x2", String.valueOf(fp.xpoints[i]));
            xsw.writeAttribute("y2", String.valueOf(fp.ypoints[i]));
            applyDefaultStyles(xsw);
            xsw.writeAttribute("stroke-linecap", "round");
            xsw.writeEndElement();
        }
    } catch(Exception e) {
        throw new SlideSetException(e);
    }
}
 
开发者ID:bnanes,项目名称:slideset,代码行数:23,代码来源:IJ1ROIsToSVGFileWriter.java

示例7: paint

import ij.gui.PointRoi; //导入依赖的package包/类
/**
 * Trigger the ROI painter using the selected index from the text panel.
 *
 * @param selectedIndex
 *            the selected index
 */
public void paint(int selectedIndex)
{
	if (selectedIndex < 0 || selectedIndex >= textPanel.getLineCount())
		return;

	ImagePlus imp = WindowManager.getImage(title);
	if (imp == null)
		return;

	double[] position = coordProvider.getCoordinates(textPanel.getLine(selectedIndex));

	if (position == null || position.length < 3)
		return;

	int slice = (int) position[0];
	double x = position[1];
	double y = position[2];

	addRoi(imp, slice, new PointRoi(x, y));

	Utils.adjustSourceRect(imp, 0, (int) x, (int) y);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:29,代码来源:ImageROIPainter.java

示例8: addRoi

import ij.gui.PointRoi; //导入依赖的package包/类
public static void addRoi(ImagePlus imp, int slice, PointRoi roi)
{
	if (imp != null && slice > 0 && slice <= imp.getStackSize())
	{
		imp.setSlice(slice);
		if (imp.getWindow() != null)
			imp.getWindow().toFront();

		if (roi != null)
		{
			//imp.setRoi(roi);

			if (imp.getStackSize() > 1)
				roi.setPosition(slice);
			Overlay o = new Overlay(roi);
			o.setStrokeColor(Color.green);
			imp.setOverlay(o);
		}
		else
		{
			imp.setOverlay(null);
		}
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:25,代码来源:ImageROIPainter.java

示例9: createRoi

import ij.gui.PointRoi; //导入依赖的package包/类
private Roi createRoi(ConvexHull hull, boolean forcePolygon)
{
	// Convert the Hull to the correct image scale.
	float[] x2 = hull.x.clone();
	float[] y2 = hull.y.clone();
	for (int i = 0; i < x2.length; i++)
	{
		x2[i] = image.mapX(x2[i]);
		y2[i] = image.mapY(y2[i]);
	}
	// Note: The hull can be a single point or a line
	if (!forcePolygon)
	{
		if (x2.length == 1)
			return new PointRoi(x2[0], y2[0]);
		if (x2.length == 2)
			return new Line(x2[0], y2[0], x2[1], y2[1]);
	}
	return new PolygonRoi(x2, y2, Roi.POLYGON);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:21,代码来源:OPTICS.java

示例10: createLabels

import ij.gui.PointRoi; //导入依赖的package包/类
private Roi createLabels(LinkedList<ChainCode> chainCodes)
{
	int nPoints = 0;
	int[] xPoints = new int[chainCodes.size()];
	int[] yPoints = new int[xPoints.length];
	for (ChainCode code : chainCodes)
	{
		int x = code.getX();
		int y = code.getY();
		int[] run = code.getRun();
		for (int i=0; i<run.length/2; i++)
		{
			x += ChainCode.DIR_X_OFFSET[run[i]];
			y += ChainCode.DIR_Y_OFFSET[run[i]];
		}
		xPoints[nPoints] = x;
		yPoints[nPoints] = y;
		nPoints++;
	}
	return new PointRoi(xPoints, yPoints, nPoints);
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:22,代码来源:ThreadAnalyser.java

示例11: setup

import ij.gui.PointRoi; //导入依赖的package包/类
public int setup(String arg, ImagePlus imp)
{
	UsageTracker.recordPlugin(this.getClass(), arg);

	if (imp == null)
	{
		return DONE;
	}
	if (imp.getRoi() == null || imp.getRoi().getType() != ij.gui.PolygonRoi.POINT)
	{
		IJ.error("Please select a centre point using the ROI tool");
		return DONE;
	}
	this.imp = imp;
	kernels = null;
	roi = (PointRoi) imp.getRoi();
	xpoints = roi.getPolygon().xpoints;
	ypoints = roi.getPolygon().ypoints;

	return flags;
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:22,代码来源:Cell_Outliner.java

示例12: addOverlay

import ij.gui.PointRoi; //导入依赖的package包/类
/**
 * Adds an ROI point overlay to the image using the specified colour
 * 
 * @param imp
 * @param list
 * @param color
 */
public static void addOverlay(ImagePlus imp, List<? extends Coordinate> list, Color color)
{
	if (list.isEmpty())
		return;

	Color strokeColor = color;
	Color fillColor = color;

	Overlay o = imp.getOverlay();
	PointRoi roi = (PointRoi) PointManager.createROI(list);
	roi.setStrokeColor(strokeColor);
	roi.setFillColor(fillColor);
	roi.setShowLabels(false);

	if (o == null)
	{
		imp.setOverlay(roi, strokeColor, 2, fillColor);
	}
	else
	{
		o.add(roi);
		imp.setOverlay(o);
	}
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:32,代码来源:FileMatchCalculator.java

示例13: createPointRoi

import ij.gui.PointRoi; //导入依赖的package包/类
private static PointRoi createPointRoi(int[] ids, int[] xpoints, int[] ypoints, int slice, int npoints,
		boolean hideLabels)
{
	// Use a custom PointRoi so we can draw the labels
	PointRoi2 roi = new PointRoi2(xpoints, ypoints, npoints);
	if (hideLabels)
	{
		roi.setHideLabels(hideLabels);
	}
	else
	{
		roi.setLabels(ids);
	}
	configureOverlayRoi(roi);

	// This is only applicable to single z stack images. 
	// We should call setPosition(int,int,int) for hyperstacks
	roi.setPosition(slice);

	return roi;
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:22,代码来源:FindFoci.java

示例14: createRoi

import ij.gui.PointRoi; //导入依赖的package包/类
private static PointRoi createRoi(ArrayList<FindFociResult> resultsArray, int outputType)
{
	final int nMaxima = resultsArray.size();
	final int[] xpoints = new int[nMaxima];
	final int[] ypoints = new int[nMaxima];
	for (int i = 0; i < nMaxima; i++)
	{
		final FindFociResult xy = resultsArray.get(i);
		xpoints[i] = xy.x;
		ypoints[i] = xy.y;
	}
	PointRoi roi = new PointRoi(xpoints, ypoints, nMaxima);
	if ((outputType & OUTPUT_HIDE_LABELS) != 0)
		roi.setShowLabels(false);
	return roi;
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:17,代码来源:FindFoci.java

示例15: checkManagerForRois

import ij.gui.PointRoi; //导入依赖的package包/类
private void checkManagerForRois()
{
	RoiManager manager = RoiManager.getInstance2();
	if (manager == null)
		return;

	pointRois = new PointRoi[manager.getCount()];

	// Store the point ROIs 
	int count = 0;
	for (Roi roi : manager.getRoisAsArray())
	{
		if (roi instanceof PointRoi)
		{
			pointRois[count++] = (PointRoi) roi;
		}
	}

	pointRois = Arrays.copyOf(pointRois, count);
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:21,代码来源:PointExtractorPlugin.java


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