T
- public class EllipsoidCursor<T> extends AbstractNeighborhoodCursor<T>
Cursor
that iterates over all the pixel
within the volume of a 3D ellipsoid. It is made so that if the ellipsoid
volume is made of N pixels, this cursor will go exactly over N iterations
before exhausting.
The center of the sphere is set by a EllipsoidNeighborhood
position,
allowing to use this cursor in neighborhood processing operations. The two
cursors (this one and the main one) are not linked in any way, so the method
to move the sphere center must be called every time. For instance:
Img<T> img; // ... long[] span = new long[] { 10, 20, 5 }; EllipsoidNeighborhood<T> ellipsoid = new EllipsoidNeighborhood<T>(img); ellipsoid.setSpan(span); Cursor<T> cursor = ellipsoid.cursor(); while (mainCursor.hasNext()) { mainCursor.fwd(); ellipsoid.setPosition(mainCursor); cursor.reset(); while (cursor.hasNext()) { cursor.fwd(); // Have fun here ... } }
The iteration order is always the same. Iteration starts from the middle Z
plane, and fill circles away from this plane in alternating fashion:
Z = 0, 1, -1, 2, -2, ...
. For each circle, lines are drawn in
the X positive direction from the middle line and away from it also in an
alternating fashion: Y = 0, 1, -1, 2, -2, ...
. To parse all the
pixels, a line-scan algorithm is used, relying on McIlroy's algorithm to
compute ellipse bounds efficiently. It makes intensive use of states to avoid
calling the Math.sqrt(double)
method.
EllipsoidNeighborhood
Modifier and Type | Field and Description |
---|---|
protected int[] |
position
Current relative position of the cursor, with respect to the ellipsoid
center.
|
neighborhood, ra
Constructor and Description |
---|
EllipsoidCursor(AbstractNeighborhood<T> ellipsoid) |
Modifier and Type | Method and Description |
---|---|
Sampler<T> |
copy() |
Cursor<T> |
copyCursor() |
void |
fwd() |
double |
getDistanceSquared() |
double |
getPhi() |
int[] |
getRelativePosition() |
double |
getTheta() |
boolean |
hasNext() |
void |
jumpFwd(long steps)
This dummy method just calls
Iterator.fwd() multiple times. |
T |
next() |
void |
reset() |
get, getDoublePosition, getFloatPosition, getIntPosition, getLongPosition, isOutOfBounds, localize, localize, localize, localize, numDimensions, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
localize, positionAsLongArray, positionAsPoint
localize, positionAsDoubleArray, positionAsRealPoint
protected int[] position
public EllipsoidCursor(AbstractNeighborhood<T> ellipsoid)
public void reset()
public void fwd()
public boolean hasNext()
public Sampler<T> copy()
Sampler
in the same state accessing the same
values.
It does NOT copy T, just the state of the Sampler
.
Otherwise use T.copy() if available.
Sampler.copy().get() == Sampler.get(), i.e. both hold the same
value, not necessarily the same instance (this is the case for an
ArrayCursor
for example)public void jumpFwd(long steps)
AbstractNeighborhoodCursor
Iterator.fwd()
multiple times.jumpFwd
in class AbstractNeighborhoodCursor<T>
steps
- number of steps to move forwardpublic T next()
public int[] getRelativePosition()
public double getTheta()
In spherical coordinates, the inclination is the angle between the Z axis and the line OM where O is the sphere center and M is the point location.
public double getPhi()
In spherical coordinates, the azimuth is the angle measured in the plane XY between the X axis and the line OH where O is the sphere center and H is the orthogonal projection of the point M on the XY plane.
public double getDistanceSquared()
Copyright © 2015–2022 ImgLib2. All rights reserved.