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


Java RealLocalizable类代码示例

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


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

示例1: paint

import net.imglib2.RealLocalizable; //导入依赖的package包/类
protected void paint( final RealLocalizable coords)
{
	final AccessBoxRandomAccessible< LongType > accessBoxExtendedLabels = new AccessBoxRandomAccessible<>( extendedLabels );
	final RandomAccessible< LongType > labelSource = Views.hyperSlice( accessBoxExtendedLabels, brushNormalAxis, Math.round( coords.getDoublePosition( 2 ) ) );

	final Neighborhood< LongType > sphere =
			HyperSphereNeighborhood.< LongType >factory().create(
					new long[]{
							Math.round( coords.getDoublePosition( brushNormalAxis == 0 ? 1 : 0 ) ),
							Math.round( coords.getDoublePosition( brushNormalAxis == 2 ? 1 : 2 ) ) },
					Math.round( brushRadius / Affine3DHelpers.extractScale( labelTransform, brushNormalAxis == 0 ? 1 : 0 ) ),
					labelSource.randomAccess() );

	for ( final LongType t : sphere )
		t.set( getValue() );

	dirtyLabelsInterval.touch( accessBoxExtendedLabels.createAccessInterval() );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:19,代码来源:LabelBrushController.java

示例2: applyInverse

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void applyInverse( final RealPositionable source, final RealLocalizable target )
{
	if( tps == null )
	{
		for ( int d = 0; d < target.numDimensions(); ++d )
			source.setPosition( target.getDoublePosition( d ), d );
			
		return;
	}
	
	double[] pt = new double[ tps.getNumDims() ];
	for ( int d = 0; d < tps.getNumDims(); ++d )
		pt[ d ] = target.getDoublePosition( d );
	
	double[] ptxfm = tps.apply( pt );
	
	for ( int d = 0; d < tps.getNumDims(); ++d )
		source.setPosition( ptxfm[ d ], d);
	
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:22,代码来源:TpsTransformWrapper.java

示例3: getIndexNearestTo

import net.imglib2.RealLocalizable; //导入依赖的package包/类
public int getIndexNearestTo( RealLocalizable pt, boolean isMoving )
{
	Double[] p;
	double minDist = Double.MAX_VALUE;
	int minIndex = -1;
	for( int i = 0; i < numRows; i++ )
	{
		p = getPoint( isMoving, i );
		double thisdist = squaredDistance( p, pt );
		if( thisdist < minDist )
		{
			minDist = thisdist;
			minIndex = i;
		}
	}
	return minIndex;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:18,代码来源:LandmarkTableModel.java

示例4: updateFigure

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void updateFigure(final OverlayView view, final BezierFigure figure) {
	super.updateFigure(view, figure);
	final PolygonOverlay polygonOverlay = downcastOverlay(view.getData());
	final PolygonRegionOfInterest roi = polygonOverlay.getRegionOfInterest();
	final int vertexCount = roi.getVertexCount();
	while (figure.getNodeCount() > vertexCount) {
		figure.removeNode(vertexCount);
	}
	for (int i = 0; i < vertexCount; i++) {
		final RealLocalizable vertex = roi.getVertex(i);
		final double x = vertex.getDoublePosition(0);
		final double y = vertex.getDoublePosition(1);
		if (figure.getNodeCount() == i) {
			figure.addNode(new Node(x, y));
		}
		else {
			final Node node = figure.getNode(i);
			node.mask = 0;
			Arrays.fill(node.x, x);
			Arrays.fill(node.y, y);
		}
	}
}
 
开发者ID:imagej,项目名称:imagej-ui-swing,代码行数:25,代码来源:PolygonJHotDrawAdapter.java

示例5: calculate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public RealLocalizable calculate(final IterableInterval<T> input) {
	final int numDimensions = input.numDimensions();

	final double[] output = new double[numDimensions];
	final double[] intensityValues = new double[numDimensions];

	final Cursor<T> c = input.localizingCursor();
	while (c.hasNext()) {
		c.fwd();
		for (int i = 0; i < output.length; i++) {
			output[i] += c.getDoublePosition(i) * c.get().getRealDouble();
			intensityValues[i] += c.get().getRealDouble();
		}
	}

	for (int i = 0; i < output.length; i++) {
		output[i] = output[i] / intensityValues[i];
	}

	return new RealPoint(output);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:DefaultCenterOfGravity.java

示例6: compute

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void compute(final Polygon input, final DoubleType output) {
	final List<? extends RealLocalizable> minBB = minimumBoundingBoxFunc.calculate(input).getVertices();

	final RealLocalizable p1 = minBB.get(0);
	final RealLocalizable p2 = minBB.get(1);
	final RealLocalizable p3 = minBB.get(2);

	double width = Math.sqrt(Math.pow(p1.getDoublePosition(0) - p2.getDoublePosition(0), 2)
			+ Math.pow(p1.getDoublePosition(1) - p2.getDoublePosition(1), 2));
	double length = Math.sqrt(Math.pow(p2.getDoublePosition(0) - p3.getDoublePosition(0), 2)
			+ Math.pow(p2.getDoublePosition(1) - p3.getDoublePosition(1), 2));

	if (width > length) {
		final double tmp = width;
		width = length;
		length = tmp;
	}
	output.set(1d - (width / length));
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:DefaultElongation.java

示例7: calculate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public Pair<RealLocalizable, RealLocalizable> calculate(Polygon input) {
	final List<? extends RealLocalizable> points = function.calculate(input).getVertices();

	double distance = Double.NEGATIVE_INFINITY;
	RealLocalizable p0 = points.get(0);
	RealLocalizable p1 = points.get(0);
	for (int i = 0; i < points.size(); i++) {
		for (int j = i + 2; j < points.size(); j++) {
			final RealLocalizable tmpP0 = points.get(i);
			final RealLocalizable tmpP1 = points.get(j);

			final double tmp = Math.sqrt(Math.pow(tmpP0.getDoublePosition(0) - tmpP1.getDoublePosition(0), 2)
					+ Math.pow(tmpP0.getDoublePosition(1) - tmpP1.getDoublePosition(1), 2));

			if (tmp > distance) {
				distance = tmp;
				p0 = tmpP0;
				p1 = tmpP1;
			}
		}
	}
	
	return new ValuePair<>(p0, p1);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:26,代码来源:DefaultMaximumFeret.java

示例8: compute

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void compute(Polygon input, DoubleType output) {
	final List<? extends RealLocalizable> points = function.calculate(input).getVertices();

	final double angleRad = -angle * Math.PI / 180.0;
	
	double minX = Double.POSITIVE_INFINITY;
	double maxX = Double.NEGATIVE_INFINITY;
	
	for (RealLocalizable p : points) {
		final double tmpX = p.getDoublePosition(0) * Math.cos(angleRad) - p.getDoublePosition(1) * Math.sin(angleRad);
		minX = tmpX < minX ? tmpX : minX;
		maxX = tmpX > maxX ? tmpX : maxX;
	}
	
	output.set(Math.abs(maxX - minX));
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:18,代码来源:DefaultFeretsDiameterForAngle.java

示例9: rotate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
/**
 * Rotates the given Polygon consisting of a list of RealPoints by the given
 * angle about the given center.
 *
 * @param inPoly A Polygon consisting of a list of RealPoint RealPoints
 * @param angle the rotation angle
 * @param center the rotation center
 * @return a rotated polygon
 */
private Polygon rotate(final Polygon inPoly, final double angle,
	final RealLocalizable center)
{

	List<RealLocalizable> out = new ArrayList<>();

	for (RealLocalizable RealPoint : inPoly.getVertices()) {

		// double angleInRadians = Math.toRadians(angleInDegrees);
		double cosTheta = Math.cos(angle);
		double sinTheta = Math.sin(angle);

		double x = cosTheta * (RealPoint.getDoublePosition(0) - center
			.getDoublePosition(0)) - sinTheta * (RealPoint.getDoublePosition(1) -
				center.getDoublePosition(1)) + center.getDoublePosition(0);

		double y = sinTheta * (RealPoint.getDoublePosition(0) - center
			.getDoublePosition(0)) + cosTheta * (RealPoint.getDoublePosition(1) -
				center.getDoublePosition(1)) + center.getDoublePosition(1);

		out.add(new RealPoint(x, y));
	}

	return new Polygon(out);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:35,代码来源:DefaultSmallestEnclosingRectangle.java

示例10: compute

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void compute(final Polygon input, final DoubleType output) {
	double perimeter = 0;
	final List<? extends RealLocalizable> vertices = input.getVertices();
	final int size = vertices.size();
	for (int i = 0; i < size; i++) {
		final int nexti = (i + 1) % size;

		final double dx2 = vertices.get(nexti).getDoublePosition(0) - vertices.get(i).getDoublePosition(0);
		final double dy2 = vertices.get(nexti).getDoublePosition(1) - vertices.get(i).getDoublePosition(1);

		perimeter += Math.sqrt(dx2 * dx2 + dy2 * dy2);
	}

	output.set(perimeter);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:DefaultPerimeterLength.java

示例11: compute

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public void compute(Polygon input, DoubleType output) {
	double sum = 0;
	final int numVertices = input.getVertices().size();
	for (int i = 0; i < numVertices; i++) {

		final RealLocalizable p0 = input.getVertices().get(i);
		final RealLocalizable p1 = input.getVertices().get((i + 1) % numVertices);

		final double p0_x = p0.getDoublePosition(0);
		final double p0_y = p0.getDoublePosition(1);
		final double p1_x = p1.getDoublePosition(0);
		final double p1_y = p1.getDoublePosition(1);

		sum += p0_x * p1_y - p0_y * p1_x;
	}
	output.set(Math.abs(sum) / 2d);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:DefaultSizePolygon.java

示例12: calculate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public RealLocalizable calculate(final IterableInterval<?> input) {
	int numDimensions = input.numDimensions();
	double[] output = new double[numDimensions];
	Cursor<?> c = input.localizingCursor();
	double[] pos = new double[numDimensions];
	while (c.hasNext()) {
		c.fwd();
		c.localize(pos);
		for (int i = 0; i < output.length; i++) {
			output[i] += pos[i];
		}
	}

	for (int i = 0; i < output.length; i++) {
		output[i] = output[i] / input.size();
	}

	return new RealPoint(output);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:CentroidII.java

示例13: calculate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public Mesh calculate(final Mesh input) {
	DefaultMesh output = new DefaultMesh();
	Set<Vertex> vertices = new LinkedHashSet<>();
	for (final RealLocalizable v : input.getVertices()) {
		vertices.add(new Vertex(v.getDoublePosition(0), v.getDoublePosition(1), v
			.getDoublePosition(2)));
	}
	List<TriangularFacet> facets = new ArrayList<>();
	List<TriangularFacet> facetsWithPointInFront = new ArrayList<>();
	final double epsilon = computeHull(vertices, facets,
		facetsWithPointInFront);
	for (TriangularFacet f : facets) {
		output.addFace(f);
	}
	output.setEpsilon(epsilon);
	return output;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:DefaultConvexHull3D.java

示例14: calculate

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Override
public RealLocalizable calculate(final Polygon input) {

	double area = sizeFunc.calculate(input).get();
	double cx = 0;
	double cy = 0;
	for (int i = 0; i < input.getVertices().size(); i++) {
		RealLocalizable p0 = input.getVertices().get(i);
		RealLocalizable p1 = input.getVertices().get((i + 1) % input.getVertices()
				.size());

		double p0_x = p0.getDoublePosition(0);
		double p0_y = p0.getDoublePosition(1);
		double p1_x = p1.getDoublePosition(0);
		double p1_y = p1.getDoublePosition(1);

		cx += (p0_x + p1_x) * (p0_x * p1_y - p1_x * p0_y);
		cy += (p0_y + p1_y) * (p0_x * p1_y - p1_x * p0_y);
	}

	return new RealPoint(cx / (area * 6), cy / (area * 6));
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:CentroidPolygon.java

示例15: quickhull_6_Test

import net.imglib2.RealLocalizable; //导入依赖的package包/类
@Test
public void quickhull_6_Test() {
	LinkedHashSet<RealLocalizable> points = new LinkedHashSet<>();
	points.add(new Vertex(3.2, 4.8, 4.4));
	points.add(new Vertex(0, -4.9, 1.1));
	points.add(new Vertex(-2.4, 4.9, -3.1));
	points.add(new Vertex(4.5, -0.9, -2.5));
	points.add(new Vertex(-4.7, 0.4, -4.2));
	points.add(new Vertex(-1.9, 2.2, -3.3));

	DefaultMesh df = new DefaultMesh(points);

	DefaultMesh convexHull = (DefaultMesh) ops.run(DefaultConvexHull3D.class, df);
	assertTrue(isConvex(convexHull.getFacets(), convexHull.getEpsilon()));
	assertEquals(5, convexHull.getVertices().size());
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:QuickHull3DTest.java


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