T
- public final class SphereCursor<T extends Type<T>> extends DomainCursor<T>
LocalizableCursor
that iterates over all the pixel within the volume
of a 3D ball, whose center and radius are given at construction. It is made so that
if the ball volume is made of N pixels, this cursor will go exactly over N iterations
before exhausting.
It takes a spatial calibration into account, which may be non isotropic, so that the region
iterated over is a sphere in physical coordinates.
The center of the sphere can be set to a LocalizableCursor
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:
Imageimg; // ... float radius = 10; LocalizableCursorr< T > mainCursor = img.createLocalizableCursor(); SphereCursor< T > sphereCursor = new SphereCursorr< T >(img, mainCursor, radius); while (mainCursor.hasNext()) { mainCursor.fwd(); sphereCursor.moveCenterTo(mainCursor); while (sphereCursor.hasNext()) { sphereCursor.fwd(); // Have fun here ... } } sphereCursor.close(); mainCursor.close();
Bounding box: if we assume for instance that the calibration is 1 in every direction,
then the whole ball will be contained in a cube which side is 2 * ceil(radius) + 1
.
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.
Internally, this cursor relies on a LocalizableByDimCursor
. It makes intensive use
of states to avoid calling the Math.sqrt(double)
method.
size
calibration, origin, position
cursor, hasNext, img
Constructor and Description |
---|
SphereCursor(Image<T> img,
double[] center,
double radius)
Construct a
SphereCursor on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. |
SphereCursor(Image<T> img,
double[] center,
double radius,
double[] calibration)
Construct a
SphereCursor on a 3D image with a given spatial calibration,
using a default OutOfBoundsStrategyValueFactory to handle off-bounds locations. |
SphereCursor(Image<T> img,
float[] center,
float radius)
Construct a
SphereCursor on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. |
SphereCursor(Image<T> img,
float[] center,
float radius,
float[] calibration)
Construct a
SphereCursor on a 3D image with a given spatial calibration,
using a default OutOfBoundsStrategyValueFactory to handle off-bounds locations. |
SphereCursor(Image<T> img,
float[] center,
float radius,
float[] calibration,
OutOfBoundsStrategyFactory<T> outOfBoundsFactory)
Construct a
SphereCursor on a 3D image with a given spatial calibration. |
SphereCursor(Image<T> img,
Localizable centerCursor,
float radius)
Construct a
SphereCursor on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. |
SphereCursor(Image<T> img,
Localizable centerCursor,
float radius,
float[] calibration)
Construct a
SphereCursor on a 3D image, using the given spatial calibration
and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. |
SphereCursor(Image<T> img,
Localizable centerCursor,
float radius,
float[] calibration,
OutOfBoundsStrategyFactory<T> outOfBoundsFactory)
Construct a
SphereCursor on a 3D image with a given spatial calibration
and a given OutOfBoundsStrategyFactory to handle off-bounds locations. |
Modifier and Type | Method and Description |
---|---|
void |
fwd() |
int |
getNPixels()
Return the number of pixels this cursor will iterate on (or, the number of iterations
it will do before exhausting).
|
double |
getPhi()
Return the azimuth of the spherical coordinates of this cursor, with respect
to its center.
|
double |
getTheta()
Return the current inclination with respect to this sphere center.
|
void |
reset() |
void |
setSize(float size)
Change the radius of the sphere this cursor iterates on.
|
getDistanceSquared, getPhysicalRelativeCoordinates, getRelativePosition, moveCenterTo, moveCenterToCoordinates, moveCenterToPosition
close, createPositionArray, fwd, getArrayIndex, getDimensions, getDimensions, getImage, getNumDimensions, getPosition, getPosition, getPosition, getPositionAsString, getStorageContainer, getStorageIndex, getType, hasNext, isActive, iterator, next, remove, setDebug
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
forEach, spliterator
public SphereCursor(Image<T> img, float[] center, float radius, float[] calibration, OutOfBoundsStrategyFactory<T> outOfBoundsFactory)
SphereCursor
on a 3D image with a given spatial calibration.img
- the image, must be 3Dcenter
- the ball center, in physical unitsradius
- the ball radius, in physical unitscalibration
- the spatial calibration (pixel size); if null
,
a calibration of 1 in all directions will be usedoutOfBoundsFactory
- the OutOfBoundsStrategyFactory
that will be used to handle off-bound locationspublic SphereCursor(Image<T> img, float[] center, float radius, float[] calibration)
SphereCursor
on a 3D image with a given spatial calibration,
using a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations.img
- the image, must be 3Dcenter
- the ball center, in physical unitsradius
- the ball radius, in physical unitscalibration
- the spatial calibration (pixel size); if null
,
a calibration of 1 in all directions will be usedpublic SphereCursor(Image<T> img, double[] center, double radius, double[] calibration)
SphereCursor
on a 3D image with a given spatial calibration,
using a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations.img
- the image, must be 3Dcenter
- the ball center, in physical unitsradius
- the ball radius, in physical unitscalibration
- the spatial calibration (pixel size); if null
,
a calibration of 1 in all directions will be usedpublic SphereCursor(Image<T> img, float[] center, float radius)
SphereCursor
on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations.img
- the image, must be 3Dcenter
- the ball center, in physical unitsradius
- the ball radius, in physical unitsImage.setCalibration(float[])
public SphereCursor(Image<T> img, double[] center, double radius)
SphereCursor
on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations.img
- the image, must be 3Dcenter
- the ball center, in physical unitsradius
- the ball radius, in physical unitsImage.setCalibration(float[])
public SphereCursor(Image<T> img, Localizable centerCursor, float radius, float[] calibration, OutOfBoundsStrategyFactory<T> outOfBoundsFactory)
SphereCursor
on a 3D image with a given spatial calibration
and a given OutOfBoundsStrategyFactory
to handle off-bounds locations.
The center of the sphere is set by the Localizable
given in argument.img
- the image, must be 3DcenterCursor
- the localizable object which position will set the sphere centerradius
- the ball radius, in physical unitscalibration
- the spatial calibration (pixel size); if null
,
a calibration of 1 in all directions will be usedpublic SphereCursor(Image<T> img, Localizable centerCursor, float radius, float[] calibration)
SphereCursor
on a 3D image, using the given spatial calibration
and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. The center of the sphere
is set by the Localizable
given in argument.img
- the image, must be 3DcenterCursor
- the cursor which position will set the sphere centerradius
- the ball radius, in physical unitspublic SphereCursor(Image<T> img, Localizable centerCursor, float radius)
SphereCursor
on a 3D image, using the spatial calibration
stored in the image and a default OutOfBoundsStrategyValueFactory
to handle off-bounds locations. The center of the sphere
is set by the Localizable
given in argument.img
- the image, must be 3DcenterCursor
- the localizable object which position will set the sphere centerradius
- the ball radius, in physical unitspublic int getNPixels()
AbstractSpecialCursor
DiscCursordc = new DiscCursor(img, center, 5); int arrraySize = sc.getNPixels(); float[] pixelVal = new float[arraySize]; int index = 0; while (sc.hasNext()) { sc.fwd(); pixelVal[index] = sc.getType().getRealFloat(); index++; }
getNPixels
in class AbstractSpecialCursor<T extends Type<T>>
public void setSize(float size)
setSize
in class DomainCursor<T extends Type<T>>
size
- the radius to setpublic final 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 final 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 final void fwd()
public final void reset()
Copyright © 2015–2021 Fiji. All rights reserved.