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


Java ShapeRoi类代码示例

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


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

示例1: makePolygon

import ij.gui.ShapeRoi; //导入依赖的package包/类
@Deprecated
public static Roi makePolygon(Point2D[] points, double strokeWidth, Color color) {
	Path2D poly = new Path2D.Double();
	if (points.length > 0) {
		poly.moveTo(points[0].getX(), points[0].getY());
		for (int i = 1; i < points.length; i++) {
			poly.lineTo(points[i].getX(), points[i].getY());
		}
		poly.closePath();
	}
	Roi shapeRoi = new ShapeRoi(poly);
	shapeRoi.setStrokeWidth(strokeWidth);
	shapeRoi.setStrokeColor(color);
	return shapeRoi;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:16,代码来源:RoiUtils.java

示例2: convertToIJRoi

import ij.gui.ShapeRoi; //导入依赖的package包/类
public static <T extends PathImage<ImagePlus>> Roi convertToIJRoi(ROI pathROI, double xOrigin, double yOrigin, double downsampleFactor) {
		if (pathROI instanceof PolygonROI)
			return convertToPolygonROI((PolygonROI)pathROI, xOrigin, yOrigin, downsampleFactor);
		if (pathROI instanceof RectangleROI)
			return getRectangleROI((RectangleROI)pathROI, xOrigin, yOrigin, downsampleFactor);
		if (pathROI instanceof EllipseROI)
			return convertToOvalROI((EllipseROI)pathROI, xOrigin, yOrigin, downsampleFactor);
		if (pathROI instanceof LineROI)
			return convertToLineROI((LineROI)pathROI, xOrigin, yOrigin, downsampleFactor);
		if (pathROI instanceof PointsROI)
			return convertToPointROI((PointsROI)pathROI, xOrigin, yOrigin, downsampleFactor);
		// If we have any other kind of shape, create a general shape roi
		if (pathROI instanceof AreaROI) { // TODO: Deal with non-AWT area ROIs!
			if (!(pathROI instanceof AWTAreaROI))
				pathROI = new AWTAreaROI((AreaROI)pathROI);
			Shape shape = ((AWTAreaROI)pathROI).getShape();
//			"scaleX", "shearY", "shearX", "scaleY", "translateX", "translateY"
			shape = new AffineTransform(1.0/downsampleFactor, 0, 0, 1.0/downsampleFactor, xOrigin, yOrigin).createTransformedShape(shape);
			return setIJRoiProperties(new ShapeRoi(shape), pathROI);
		}
		// TODO: Integrate ROI not supported exception...?
		return null;		
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:24,代码来源:ROIConverterIJ.java

示例3: convertToPathROI

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

示例4: updateShapes

import ij.gui.ShapeRoi; //导入依赖的package包/类
private void updateShapes(final ImagePlus imp) {

        lastSourceImage = imp;

        if (imp == null) {
            return;
        }

        // Prepare overlay
        final Overlay overlay = new Overlay();
        for (final Region region : regions) {

            final Area area = new Area();
            for (final SubRegion subRegion : region.getSubRegions()) {
                final Shape shape = ShapeUtils.toShape(subRegion.getRoi());
                area.add(new Area(shape));
            }
            final ShapeRoi roi = new ShapeRoi(area);
            roi.setStrokeColor(region.getColor());
            roi.setFillColor(region.getColor());
            roi.setName(region.getName());
            overlay.add(roi);
        }

        imp.setOverlay(overlay);
    }
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:27,代码来源:MultiRegionManagerModel.java

示例5: toShape

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

示例6: writeOverlay

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

示例7: actionPerformed

import ij.gui.ShapeRoi; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
	ImagePlus imp = WindowManager.getImage(results.getName() + " " + TITLE);
	if (imp == null || output == null)
		return;

	// List the ROIs
	Roi imageRoi = imp.getRoi();
	if (imageRoi == null || !imageRoi.isArea())
		return;
	Roi[] rois;
	if (imageRoi instanceof ShapeRoi)
		rois = ((ShapeRoi) imageRoi).getRois();
	else
		rois = new Roi[] { imageRoi };

	for (int i = 0; i < rois.length; i++)
	{
		drawLoop(imp, rois[i], i + 1);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:22,代码来源:PulseActivationAnalysis.java

示例8: checkForSkeletonForks

import ij.gui.ShapeRoi; //导入依赖的package包/类
void checkForSkeletonForks(ShapeRoi roi, VPoint[] oldEndpoints) {
	ImageProcessor skeleton = MovieProcessor.skeletonize(roi);
	VPoint[] endpoints = MovieProcessor.getSkeletonEndpoints((ByteProcessor)skeleton);
	if (endpoints.length != 2) {
		log.debug("Fork check FAILED:");
		ControlPanel.addStatusMessage("  Fork check failed - probably a 'bubble' growing out of selection - please correct the selection manually.");
		for (int i=0; i < endpoints.length; ++i) {
			log.debug("\tNew endpoint " + endpoints[i] + 
					" min distance = " + Math.min(oldEndpoints[0].distanceTo(endpoints[i]), oldEndpoints[1].distanceTo(endpoints[i]))
					);
			
		}
	} else {
		log.debug("Fork check PASSED.");
	}
}
 
开发者ID:mekterovic,项目名称:bactimas,代码行数:17,代码来源:CopyAndAdjustAlgorithm.java

示例9: part

import ij.gui.ShapeRoi; //导入依赖的package包/类
/** Subtracts the given ROI, and then creates a new AreaList with identical properties and the content of the subtracted part. Returns null if there is no intersection between sroi and the Area for layer_id. */
public AreaList part(final long layer_id, final ShapeRoi sroi) throws NoninvertibleTransformException {
	// The Area to subtract, in world coordinates:
	final Area sub = M.getArea(sroi);
	// The area to subtract from:
	final Area a = getArea(layer_id);
	if (null == a || M.isEmpty(a)) return null;
	// The intersection:
	final Area inter = a.createTransformedArea(this.at);
	inter.intersect(sub);
	if (M.isEmpty(inter)) return null;

	// Subtract from this:
	this.subtract(layer_id, sroi);

	// Create new AreaList with the intersection area, and add it to the same LayerSet as this:
	final AreaList ali = new AreaList(this.project, this.title, 0, 0);
	ali.color = new Color(color.getRed(), color.getGreen(), color.getBlue());
	ali.visible = this.visible;
	ali.alpha = this.alpha;
	ali.addArea(layer_id, inter);
	this.layer_set.add(ali); // needed to call updateBucket
	ali.calculateBoundingBox(null != layer_set ? layer_set.getLayer(layer_id) : null);

	return ali;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:27,代码来源:AreaList.java

示例10: moveBlow

import ij.gui.ShapeRoi; //导入依赖的package包/类
public void moveBlow(int dx, int dy) throws Exception {
	int x = box.width/2 + dx;
	int y = box.height/2 + dy;
	// Keep within bounds
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	if (x > box.width -1) x = box.width -1;
	if (y > box.height -1) y = box.height -1;
	lasso.moveBlow(x, y);
	// extract ROI
	Roi roi = imp.getRoi();
	if (null == roi) Display.getFront().getCanvas().getFakeImagePlus().setRoi(roi); // can't set to null? Java, gimme a break
	else {
		Roi sroi = new ShapeRoi(roi);
		Rectangle b = sroi.getBounds();
		sroi.setLocation(box.x + b.x, box.y + b.y);
		Display.getFront().getCanvas().getFakeImagePlus().setRoi(sroi);
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:20,代码来源:Segmentation.java

示例11: finish

import ij.gui.ShapeRoi; //导入依赖的package包/类
public void finish(final AreaContainer ac, final AffineTransform source_aff) throws Exception {
	Roi roi = imp.getRoi();
	Utils.log2("roi is " + roi);
	if (null == roi) return;
	ShapeRoi sroi = new ShapeRoi(roi);
	Rectangle b = sroi.getBounds();
	sroi.setLocation(box.x + b.x, box.y + b.y);

	try {
		aw.getArea().add(M.getArea(sroi).createTransformedArea(source_aff.createInverse()));
		ac.calculateBoundingBox(layer);
		Display.getFront().getCanvas().getFakeImagePlus().killRoi();
	} catch (NoninvertibleTransformException nite) {
		IJError.print(nite);
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:17,代码来源:Segmentation.java

示例12: addContours

import ij.gui.ShapeRoi; //导入依赖的package包/类
public void addContours(List<Contour> contours, Color color, double strokeWidth) {
	BasicStroke stroke = new BasicStroke((float)strokeWidth);
	for (Contour c : contours) {
		Shape s = c.getPolygonPath();
		Roi roi = new ShapeRoi(s);
		roi.setStrokeColor(color);
		roi.setStroke(stroke);
		add(roi);
	}
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:11,代码来源:ContourOverlay.java

示例13: addPath

import ij.gui.ShapeRoi; //导入依赖的package包/类
void addPath(final Shape shape, final Color color, final BasicStroke stroke) {
	final Roi roi = new ShapeRoi(shape);
	roi.setStrokeColor(color);
	roi.setStroke(stroke);
	roi.setStrokeWidth(roi.getStrokeWidth() / (float) scale);
	overlay.add(roi);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:8,代码来源:Orienteer.java

示例14: convertToPolygonOrAreaROI

import ij.gui.ShapeRoi; //导入依赖的package包/类
public static ROI convertToPolygonOrAreaROI(Roi roi, Calibration cal, double downsampleFactor, final int c, final int z, final int t) {
		Shape shape;
		if (roi instanceof ShapeRoi)
			shape = ((ShapeRoi)roi).getShape();
		else
			shape = new ShapeRoi(roi).getShape();
		AffineTransform transform = new AffineTransform();
		transform.scale(downsampleFactor, downsampleFactor);
		transform.translate(roi.getXBase(), roi.getYBase());
		if (cal != null)
			transform.translate(-cal.xOrigin, -cal.yOrigin);
		return PathROIToolsAwt.getShapeROI(new Area(transform.createTransformedShape(shape)), c, z, t);
//		return setPathROIProperties(new PathAreaROI(transform.createTransformedShape(shape)), roi);
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:15,代码来源:ROIConverterIJ.java

示例15: convertToAreaROI

import ij.gui.ShapeRoi; //导入依赖的package包/类
public static AreaROI convertToAreaROI(ShapeRoi roi, Calibration cal, double downsampleFactor, final int c, final int z, final int t) {
		Shape shape = roi.getShape();
		AffineTransform transform = new AffineTransform();
		transform.scale(downsampleFactor, downsampleFactor);
		transform.translate(roi.getXBase(), roi.getYBase());
		if (cal != null)
			transform.translate(-cal.xOrigin, -cal.yOrigin);
//		return setPathROIProperties(PathROIHelpers.getShapeROI(new Area(transform.createTransformedShape(shape)), 0, 0, 0), roi);
		return new AWTAreaROI(transform.createTransformedShape(shape), c, z, t);
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:11,代码来源:ROIConverterIJ.java


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