本文整理汇总了Java中net.imglib2.RealPoint类的典型用法代码示例。如果您正苦于以下问题:Java RealPoint类的具体用法?Java RealPoint怎么用?Java RealPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RealPoint类属于net.imglib2包,在下文中一共展示了RealPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeNormalsFromVertices
import net.imglib2.RealPoint; //导入依赖的package包/类
public float[] makeNormalsFromVertices( ArrayList<RealPoint> verts ) {
float[] normals = new float[verts.size()];// div3 * 3coords
for( int k = 0 ; k < verts.size(); k+=3 ) {
GLVector v1 = new GLVector( verts.get(k).getFloatPosition(0 ),
verts.get(k).getFloatPosition(1 ),
verts.get(k).getFloatPosition(2 ));
GLVector v2 = new GLVector( verts.get(k+1).getFloatPosition(0 ),
verts.get(k+1).getFloatPosition(1 ),
verts.get(k+1).getFloatPosition(2 ));
GLVector v3 = new GLVector( verts.get(k+2).getFloatPosition(0 ),
verts.get(k+2).getFloatPosition(1 ),
verts.get(k+2).getFloatPosition(2 ));
GLVector a = v2.minus(v1);
GLVector b = v3.minus(v1);
GLVector n = a.cross(b).getNormalized();
normals[k/3] = n.get(0);
normals[k/3+1] = n.get(1);
normals[k/3+2] = n.get(2);
}
return normals;
}
示例2: getClosestAnnotation
import net.imglib2.RealPoint; //导入依赖的package包/类
/**
* Get the closest annotation to a given display point.
*
* @param x
* @param y
* @param maxDistance Max distance to consider for the search. If no annotation exists in the search area, null is returned.
* @return
*/
private Annotation getClosestAnnotation(final int x, final int y, final double maxDistance) {
final RealPoint pos = new RealPoint(3);
viewer.displayToGlobalCoordinates(x, y, pos);
System.out.println("clicked at global coordinates " + pos);
final List< Annotation > closest = annotations.getKNearest(pos, 1);
if (closest.size() == 0)
return null;
final double[] a = new double[3];
final double[] b = new double[3];
pos.localize(a);
closest.get(0).getPosition().localize(b);
final double distance = LinAlgHelpers.distance(a, b);
if (distance <= maxDistance)
return closest.get(0);
return null;
}
示例3: click
import net.imglib2.RealPoint; //导入依赖的package包/类
@Override
public void click(final int x, final int y) {
final Annotation active = selection.getLastAdded();
if (active == null || !(active instanceof PreSynapticSite)) {
viewer.showMessage("select a pre-synaptic site before adding a post-synaptic site to it");
return;
}
final PreSynapticSite pre = (PreSynapticSite)active;
final RealPoint pos = new RealPoint(3);
viewer.displayToGlobalCoordinates(x, y, pos);
System.out.println("Adding postsynaptic site at " + pos);
final PostSynapticSite site = new PostSynapticSite(idService.next(), pos, "");
site.setPartner(pre);
pre.setPartner(site);
annotations.add(site);
selection.clear();
selection.add(site);
}
示例4: setFov
import net.imglib2.RealPoint; //导入依赖的package包/类
public void setFov(final double fov) {
synchronized (viewer) {
final RealPoint currentCenter = new RealPoint(3);
viewer.displayToGlobalCoordinates(viewer.getWidth() / 2,
viewer.getHeight() / 2, currentCenter);
final AffineTransform3D viewerTransform = new AffineTransform3D();
viewer.getState().getViewerTransform(viewerTransform);
final double currentFov = Math.min(viewer.getWidth(), viewer.getHeight())
/ Affine3DHelpers.extractScale(viewerTransform, 0);
final double scale = currentFov / fov;
System.out.println("current fov is " + currentFov
+ " in smallest dimension, want " + fov + ", scale by "
+ scale);
viewerTransform.scale(scale);
viewer.setCurrentViewerTransform(viewerTransform);
goTo(currentCenter);
}
}
示例5: click
import net.imglib2.RealPoint; //导入依赖的package包/类
@Override
public void click( final int x, final int y )
{
final long oldActiveFragmentId = selectionController.getActiveFragmentId();
final long id = idPicker.getIdAtDisplayCoordinate( x, y );
assignment.mergeFragmentSegments( oldActiveFragmentId, id );
selectionController.setActiveFragmentId( id );
viewer.requestRepaint();
final RealPoint pos = new RealPoint( 3 );
viewer.displayToGlobalCoordinates( x, y, pos );
final Merge merge = new Merge(
lastClick.getDoublePosition( 0 ),
lastClick.getDoublePosition( 1 ),
lastClick.getDoublePosition( 2),
pos.getDoublePosition( 0 ),
pos.getDoublePosition( 1 ),
pos.getDoublePosition( 2 ),
oldActiveFragmentId,
id );
merges.add( merge );
viewer.displayToGlobalCoordinates( x, y, lastClick );
System.out.println( "recoreded 'need merge' of " + oldActiveFragmentId + " with " + id );
}
示例6: paint
import net.imglib2.RealPoint; //导入依赖的package包/类
protected void paint( final int x1, final int y1, final int x2, final int y2 )
{
setCoordinates( x1, y1 );
final double[] p1 = new double[ 3 ];
final RealPoint rp1 = RealPoint.wrap( p1 );
labelLocation.localize( p1 );
setCoordinates( x2, y2 );
final double[] d = new double[ 3 ];
labelLocation.localize( d );
LinAlgHelpers.subtract( d, p1, d );
final double l = LinAlgHelpers.length( d );
LinAlgHelpers.normalize( d );
for ( int i = 1; i < l; ++i )
{
LinAlgHelpers.add( p1, d, p1 );
paint( rp1 );
}
paint( labelLocation );
}
示例7: LabelRestrictToSegmentController
import net.imglib2.RealPoint; //导入依赖的package包/类
public LabelRestrictToSegmentController(
final ViewerPanel viewer,
final RandomAccessibleInterval< LabelMultisetType > labels,
final RandomAccessibleInterval< LongType > paintedLabels,
final AffineTransform3D labelTransform,
final FragmentSegmentAssignment assignment,
final SelectionController selectionController,
final Shape shape,
final InputTriggerConfig config )
{
this.viewer = viewer;
this.labels = labels;
this.paintedLabels = paintedLabels;
this.labelTransform = labelTransform;
this.assignment = assignment;
this.selectionController = selectionController;
this.shape = shape;
inputAdder = config.inputTriggerAdder( inputTriggerMap, "restrict" );
labelLocation = new RealPoint( 3 );
new Intersect( "restrict", "shift R button1" ).register();
}
示例8: addFixedPoint
import net.imglib2.RealPoint; //导入依赖的package包/类
/**
* Adds a point in the moving and fixed images at the same point.
* @param pt the point
* @param isMovingImage is the point in moving image space
*/
public void addFixedPoint( final RealPoint pt, final boolean isMovingImage )
{
if ( isMovingImage && viewerP.getTransformEnabled() )
{
// Here we clicked in the space of the moving image
currentLandmark.localize( ptarrayLoc );
addPoint( ptarrayLoc, true, viewerP );
addPoint( ptarrayLoc, false, viewerQ );
}
else
{
currentLandmark.localize( ptarrayLoc );
addPoint( ptarrayLoc, true, viewerP );
addPoint( ptarrayLoc, false, viewerQ );
}
if ( updateWarpOnPtChange )
BigWarp.this.restimateTransformation();
}
示例9: parsePolygon
import net.imglib2.RealPoint; //导入依赖的package包/类
/** Generate an overlay from a {@code polygon} element */
private AbstractOverlay parsePolygon(Element n) throws SVGParseException {
if(!"polygon".equals(n.getTagName()))
throw new SVGParseException("\'polygon\' expected, but \'" + n.getLocalName() + "\' found.");
String points = n.getAttribute("points");
ArrayList<double[]> pts;
try {
pts = parseListOfPoints(points);
} catch(NumberFormatException e) {
throw new SVGParseException("Bad points list: " + points, e);
}
if(pts.isEmpty())
return null;
PolygonOverlay po = new PolygonOverlay(ij);
po.setAxis(new DefaultLinearAxis(Axes.X), 0);
po.setAxis(new DefaultLinearAxis(Axes.Y), 1);
PolygonRegionOfInterest poi = po.getRegionOfInterest();
for(double[] pt : pts) {
int i = poi.getVertexCount();
poi.addVertex(i, new RealPoint(transformToDocumentSpace(pt, n)));
}
return po;
}
示例10: calculate
import net.imglib2.RealPoint; //导入依赖的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);
}
示例11: rotate
import net.imglib2.RealPoint; //导入依赖的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);
}
示例12: calculate
import net.imglib2.RealPoint; //导入依赖的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);
}
示例13: calculate
import net.imglib2.RealPoint; //导入依赖的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));
}
示例14: convexHull2D
import net.imglib2.RealPoint; //导入依赖的package包/类
@Test
public void convexHull2D() {
// ground truth computed with matlab
final Polygon test = (Polygon) ops.run(DefaultConvexHull2D.class, contour);
final List<? extends RealLocalizable> received = test.getVertices();
final RealPoint[] expected = new RealPoint[] { new RealPoint(1, 30), new RealPoint(2, 29), new RealPoint(26, 6),
new RealPoint(31, 6), new RealPoint(42, 9), new RealPoint(49, 22), new RealPoint(72, 65),
new RealPoint(78, 77), new RealPoint(48, 106), new RealPoint(42, 109), new RealPoint(34, 109),
new RealPoint(28, 106), new RealPoint(26, 104), new RealPoint(23, 98) };
assertEquals("Number of polygon points differs.", expected.length, received.size());
for (int i = 0; i < expected.length; i++) {
assertEquals("Polygon point " + i + " differs in x-coordinate.", expected[i].getDoublePosition(0),
received.get(i).getDoublePosition(0), EPSILON);
assertEquals("Polygon point " + i + " differs in y-coordinate.", expected[i].getDoublePosition(1),
received.get(i).getDoublePosition(1), EPSILON);
}
}
示例15: smallesEnclosingRectangle
import net.imglib2.RealPoint; //导入依赖的package包/类
@Test
public void smallesEnclosingRectangle() {
// ground truth verified with matlab
final List<? extends RealLocalizable> received = ((Polygon) ops.run(DefaultSmallestEnclosingRectangle.class,
contour)).getVertices();
final RealPoint[] expected = new RealPoint[] { new RealPoint(37.229184188393, -0.006307821699),
new RealPoint(-14.757779646762, 27.800672834315), new RealPoint(31.725820016821, 114.704793944491),
new RealPoint(83.712783851976, 86.897813288478) };
assertEquals("Number of polygon points differs.", expected.length, received.size());
for (int i = 0; i < expected.length; i++) {
assertEquals("Polygon point " + i + " differs in x-coordinate.", expected[i].getDoublePosition(0),
received.get(i).getDoublePosition(0), EPSILON);
assertEquals("Polygon point " + i + " differs in y-coordinate.", expected[i].getDoublePosition(1),
received.get(i).getDoublePosition(1), EPSILON);
}
}