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


Java Roi类代码示例

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


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

示例1: getWarpedPointsCentered

import ij.gui.Roi; //导入依赖的package包/类
@Deprecated
public static List<Point2D> getWarpedPointsCentered(Roi roi, LinearMapping W) {
	Rectangle bounds = roi.getBounds();
	List<Point2D> oPts = new LinkedList<Point2D>();
	float xC = bounds.width/2;
	float yC = bounds.height/2;
	oPts.add(new Point2D.Float(0 - xC, 0 - yC));
	oPts.add(new Point2D.Float(bounds.width - xC, 0 - yC));
	oPts.add(new Point2D.Float(bounds.width - xC, bounds.height - yC));
	oPts.add(new Point2D.Float(0 - xC, bounds.height - yC));
	List<Point2D> wPts = new LinkedList<Point2D>();
	for (Point2D op : oPts) {
		wPts.add(W.applyTo(op));
		//pts.add(ipm);
	}
	return wPts;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:18,代码来源:RoiUtils.java

示例2: makePolygon

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

示例3: getRoiPoints

import ij.gui.Roi; //导入依赖的package包/类
static Point2D[] getRoiPoints(Roi roi) {
	Polygon poly = roi.getPolygon();
	int[] xp = poly.xpoints;
	int[] yp = poly.ypoints;
	// copy vertices for all non-zero-length polygon segments:
	List<Point> points = new ArrayList<Point>(xp.length);
	points.add(new Point(xp[0], yp[0]));
	int last = 0;
	for (int i = 1; i < xp.length; i++) {
		if (xp[last] != xp[i] || yp[last] != yp[i]) {
			points.add(new Point(xp[i], yp[i]));
			last = i;
		}
	}
	// remove last point if the closing segment has zero length:
	if (xp[last] == xp[0] && yp[last] == yp[0]) {
		points.remove(last);
	}
	return points.toArray(new Point2D[0]);
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:21,代码来源:FourierDescriptorFromPolygon.java

示例4: getSliceRoi

import ij.gui.Roi; //导入依赖的package包/类
/**
 * Return a list of ROIs that are active in the given slice, sliceNumber.
 * ROIs without a slice number are assumed to be active in all slices.
 *
 * @param roiMan an instance of {@link RoiManager}
 * @param stack a image stack
 * @param sliceNumber the number of slice in the stack.
 * @return A list of active ROIs on the slice. Returns an empty list if
 *         roiMan == null or stack == null Returns an empty list if slice
 *         number is out of bounds
 */
public static ArrayList<Roi> getSliceRoi(final RoiManager roiMan, final ImageStack stack, final int sliceNumber) {
	final ArrayList<Roi> roiList = new ArrayList<Roi>();

	if (roiMan == null || stack == null) {
		return roiList;
	}

	if (sliceNumber < 1 || sliceNumber > stack.getSize()) {
		return roiList;
	}

	final Roi[] rois = roiMan.getRoisAsArray();
	for (final Roi roi : rois) {
		final String roiName = roi.getName();
		if (roiName == null) {
			continue;
		}
		final int roiSliceNumber = roiMan.getSliceNumber(roiName);
		final int roiPosition = roi.getPosition();
		if (roiSliceNumber == sliceNumber || roiSliceNumber == NO_SLICE_NUMBER || roiPosition == sliceNumber) {
			roiList.add(roi);
		}
	}
	return roiList;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:37,代码来源:RoiMan.java

示例5: copySlice

import ij.gui.Roi; //导入依赖的package包/类
/**
 * Copies pixels under all the ROIs on a slide
 *
 * @param sourceProcessor The source image slide
 * @param targetProcessor The target slide
 * @param sliceRois List of all the ROIs on the source slide
 * @param padding Number of pixels added on each side of the target slide
 */
private static void copySlice(final ImageProcessor sourceProcessor, final ImageProcessor targetProcessor,
		final ArrayList<Roi> sliceRois, final int padding) {
	for (final Roi sliceRoi : sliceRois) {
		final Rectangle rectangle = sliceRoi.getBounds();
		final boolean valid = getSafeRoiBounds(rectangle, sourceProcessor.getWidth(), sourceProcessor.getHeight());

		if (!valid) {
			continue;
		}

		final int minY = rectangle.y;
		final int minX = rectangle.x;
		final int maxY = rectangle.y + rectangle.height;
		final int maxX = rectangle.x + rectangle.width;

		final ImageProcessor mask = sourceProcessor.getMask();
		if (mask == null) {
			copyRoi(sourceProcessor, targetProcessor, minX, minY, maxX, maxY, padding);
		} else {
			copyRoiWithMask(sourceProcessor, targetProcessor, minX, minY, maxX, maxY, padding);
		}
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:32,代码来源:RoiMan.java

示例6: testGetLimitsReturnsNullIfThereAreNoValidRois

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testGetLimitsReturnsNullIfThereAreNoValidRois() throws Exception {
	final Roi badXYRoi = new Roi(-100, -100, 10, 10);
	badXYRoi.setName("0001-0000-0001");

	final Roi badSliceRoi = new Roi(10, 10, 30, 60);
	badSliceRoi.setName("9999-0000-0001"); // slice #9999

	final Roi badRois[] = { badXYRoi, badSliceRoi };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(badRois);
	when(mockRoiManager.getCount()).thenReturn(badRois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);
	assertNull("Limits should be null if there are no valid ROIs", limitsResult);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManTest.java

示例7: testGetLimitsAccountsForRoiActiveOnAllSlides

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testGetLimitsAccountsForRoiActiveOnAllSlides() throws Exception {
	final Roi roi = new Roi(10, 10, 30, 60);
	roi.setName("0001-0000-0001");
	final Roi allActive = new Roi(80, 80, 10, 10);
	allActive.setName(""); // name can't be null
	final Roi rois[] = { roi, allActive };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);
	when(mockRoiManager.getCount()).thenReturn(rois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);

	assertEquals("Limits should start from the first slide", 1, limitsResult[MIN_Z_INDEX]);
	assertEquals("Limits should end on the last slide", testStack.getSize(), limitsResult[MAX_Z_INDEX]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManTest.java

示例8: testGetLimitsCropsTooLargeRois

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testGetLimitsCropsTooLargeRois() throws Exception {
	final int STACK_WIDTH = testStack.getWidth();
	final int STACK_HEIGHT = testStack.getHeight();
	final Roi hugeRoi = new Roi(-100, -100, STACK_WIDTH + 100, STACK_HEIGHT + 100);
	hugeRoi.setName("0001-0000-0001");
	final Roi rois[] = { hugeRoi };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);
	when(mockRoiManager.getCount()).thenReturn(rois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);
	assertEquals("Limits minimum x is incorrect", 0, limitsResult[0]);
	assertEquals("Limits maximum x is incorrect", STACK_WIDTH, limitsResult[1]);
	assertEquals("Limits minimum y is incorrect", 0, limitsResult[2]);
	assertEquals("Limits maximum y is incorrect", STACK_HEIGHT, limitsResult[3]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:RoiManTest.java

示例9: getSliceRoi

import ij.gui.Roi; //导入依赖的package包/类
/**
 * Returns a list of ROIs that are active in the given slice.
 *
 * @param roiMan the collection of all the current ROIs.
 * @param stack the 3D stack where the ROIs are.
 * @param sliceNumber number of the slice to be searched.
 * @return in addition to the active ROIs, returns all the ROIs without a
 *         slice number (assumed to be active in all slices). Returns an empty
 *         list if sliceNumber is out of bounds, or roiMan == null, or stack
 *         == null
 */
public static List<Roi> getSliceRoi(final RoiManager roiMan,
	final ImageStack stack, final int sliceNumber)
{
	final List<Roi> roiList = new ArrayList<>();

	if (roiMan == null || stack == null || sliceNumber < FIRST_SLICE_NUMBER ||
		sliceNumber > stack.getSize())
	{
		return roiList;
	}

	final Roi[] rois = roiMan.getRoisAsArray();
	for (Roi roi : rois) {
		String roiName = roi.getName();
		if (roiName == null) {
			continue;
		}
		int roiSliceNumber = roiMan.getSliceNumber(roiName);
		if (roiSliceNumber == sliceNumber || roiSliceNumber == NO_SLICE_NUMBER) {
			roiList.add(roi);
		}
	}
	return roiList;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:36,代码来源:RoiManagerUtil.java

示例10: pointROICoordinates

import ij.gui.Roi; //导入依赖的package包/类
/**
 * Gets the coordinates of all point ROIs in the manager.
 * <p>
 * NB z-coordinates start from 1. If a ROI is not associated with a slice,
 * it's z = 0.
 * </p>
 *
 * @param manager an instance of {@link RoiManager}.
 * @return point ROI coordinates.
 */
public static List<Vector3d> pointROICoordinates(final RoiManager manager) {
	if (manager == null) {
		return Collections.emptyList();
	}
	final Roi[] rois = manager.getRoisAsArray();
	// To be completely accurate, we'd have to calculate the centers of the ROIs
	// bounding boxes, but since we're only interested in point ROIs that won't
	// make a huge difference.
	return Arrays.stream(rois).filter(roi -> roi.getType() == Roi.POINT).map(
		roi -> {
			final double x = roi.getXBase();
			final double y = roi.getYBase();
			final int z = roi.getZPosition();
			return new Vector3d(x, y, z);
		}).collect(Collectors.toList());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:27,代码来源:RoiManagerUtil.java

示例11: testGetLimitsAllActiveSlide

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testGetLimitsAllActiveSlide() throws Exception {
	// Mock a RoiManager with Rois
	final Roi roi = new Roi(0, 0, 10, 10);
	final Roi allActive = new Roi(0, 0, 10, 10);
	final Roi rois[] = { roi, allActive };
	roi.setName("0001-0000-0001");
	allActive.setName("ALL_ACTIVE");
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);

	Optional<int[]> result = RoiManagerUtil.getLimits(MOCK_ROI_MANAGER,
		testStack);
	assertTrue(result.isPresent());
	final int[] limits = result.get();
	assertEquals(1, limits[MIN_Z_INDEX]);
	assertEquals(testStack.size(), limits[MAX_Z_INDEX]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:RoiManagerUtilTest.java

示例12: testGetLimitsIgnoresBadRois

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testGetLimitsIgnoresBadRois() throws Exception {
	// Mock a RoiManager with invalid Rois
	final Roi farZRoi = new Roi(10, 10, 10, 10);
	final Roi badRoi = new Roi(-100, -100, 10, 10);
	final Roi rois[] = { farZRoi, badRoi };
	farZRoi.setName("9999-0000-0001"); // slice no == 9999
	badRoi.setName("0001-0000-0001");
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);

	Optional<int[]> result = RoiManagerUtil.getLimits(MOCK_ROI_MANAGER,
		testStack);

	assertFalse(result.isPresent());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManagerUtilTest.java

示例13: testPointRoiCoordinates

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

示例14: testCleanDuplicate

import ij.gui.Roi; //导入依赖的package包/类
@Test
public void testCleanDuplicate() throws Exception {
    final String title = "bonej-test-image.tiff";
    final int width = 5;
    final int height = 7;
    final int depth = 11;
    final Roi roi = new Roi(1, 1, 3, 3);
    final ImagePlus image = IJ.createImage(title, width, height, depth, 8);
    image.setRoi(roi);

    final ImagePlus result = ImagePlusUtil.cleanDuplicate(image);

    assertEquals("Duplicate has wrong title", result.getTitle(), title);
    assertEquals("ROI should not affect duplicate size", width, result
            .getWidth());
    assertEquals("ROI should not affect duplicate size", height, result
            .getHeight());
    assertEquals("The original image should still have its ROI", roi, image
            .getRoi());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:21,代码来源:ImagePlusUtilTest.java

示例15: createRoiBox

import ij.gui.Roi; //导入依赖的package包/类
/**
 * Create JComboBox for selecting ROIs created in ImageJ.
 * @return
 */
public static JComboBox<String> createRoiBox(){
	String[] imageTitles = WindowManager.getImageTitles();
	
	ArrayList<String> elements = new ArrayList<String>(imageTitles.length); 
	for(String s: imageTitles){
		ImagePlus ip = WindowManager.getImage(s);
		Roi roi = ip.getRoi();
		if(roi != null){
			elements.add(s);
		}
	}

	JComboBox<String> roiBox = new JComboBox<String>(imageTitles);
	roiBox.setEditable(false);
	roiBox.setMaximumRowCount(BOXSIZE);
	
	ImageWindow win = WindowManager.getCurrentWindow();
	if(win != null){
		if(elements.contains(win.getTitle())){
roiBox.setSelectedItem(win.getName());
		}
	}
	return roiBox;
}
 
开发者ID:m4dguy,项目名称:CVForge,代码行数:29,代码来源:InputHelpers.java


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