public interface RandomAccessibleView<T,V extends RandomAccessibleView<T,V>> extends RandomAccessible<T>
RandomAccessible.
A view is itself a RandomAccessible or RandomAccessibleInterval whose accessors transform coordinates and/or values
on-the-fly without copying the underlying data. Consecutive transformations
are concatenated and simplified to provide optimally efficient accessors.
The RandomAccessibleView gateway implements RandomAccessible,
forwarding all methods to its delegate(). Additionally, it provides
methods analogous to the static Views methods that operate on
its delegate() and return RandomAccessibleIntervalView, RandomAccessibleView, or RealRandomAccessibleView wrappers.
This provides a fluent API for conveniently chaining Views methods.
For example
RandomAccessible< IntType > view =
img.view()
.extend( Extension.mirrorSingle() )
.permute( 0, 1 )
.translate( 10, 10 );
Views| Modifier and Type | Interface and Description |
|---|---|
static class |
RandomAccessibleView.Interpolation<T>
Interpolation method to use with
interpolate(net.imglib2.view.fluent.RandomAccessibleView.Interpolation<T>). |
| Modifier and Type | Method and Description |
|---|---|
default RandomAccessibleView<T,?> |
addDimension()
Create a (n+1)-dimensional view of this n-dimensional
RandomAccessible, by replicating values along the added axis. |
default <U> RandomAccessibleView<U,?> |
convert(Supplier<U> targetSupplier,
Converter<? super T,? super U> converter)
Create a view of this
RandomAccessible converted to pixel type
U. |
default <U> RandomAccessibleView<U,?> |
convert(Supplier<U> targetSupplier,
Supplier<Converter<? super T,? super U>> converterSupplier)
Create a view of this
RandomAccessible converted to pixel type
U. |
RandomAccessible<T> |
delegate() |
default T |
getType()
Get an instance of
T. |
default RealRandomAccessibleView<T> |
interpolate(RandomAccessibleView.Interpolation<T> interpolation)
Create a
RealRandomAccessible view of this RandomAccessible
using interpolation with the given interpolation method. |
default RandomAccessibleIntervalView<T> |
interval(Interval interval)
Define an interval on this
RandomAccessible. |
default RandomAccessibleView<T,?> |
invertAxis(int axis)
Invert the
axis with the given index. |
default RandomAccessibleView<T,?> |
moveAxis(int fromAxis,
int toAxis)
Create a view with permuted axes where the specified
fromAxis is
moved to index toAxis while the order of other axes is preserved. |
default int |
numDimensions()
Gets the space's number of dimensions.
|
default RandomAccessibleView<T,?> |
permute(int fromAxis,
int toAxis)
Create a view with permuted axes where the specified
fromAxis to
toAxis are swapped (while all other axes remain unchanged). |
default RandomAccess<T> |
randomAccess()
Create a random access sampler for integer coordinates.
|
default RandomAccess<T> |
randomAccess(Interval interval)
Create a random access sampler for integer coordinates.
|
default RandomAccessibleView<T,?> |
rotate(int fromAxis,
int toAxis)
Create a view rotated 90 degrees, mapping
fromAxis to toAxis. |
default RandomAccessibleView<T,?> |
slice(int d,
long pos)
Take a (n-1)-dimensional slice of this n-dimensional
RandomAccessible, by fixing the d dimension of
coordinates to pos. |
default RandomAccessibleView<T,?> |
subsample(long... steps)
Sample only every stepdth value of a
source
RandomAccessible. |
default RandomAccessibleView<T,?> |
translate(long... translation)
Create a view that is translated by the given
translation vector. |
default RandomAccessibleView<T,?> |
translateInverse(long... translation)
Create a view that is translated by the inverse of the given
translation vector. |
default <U> U |
use(Function<? super V,U> function)
Apply the specified
function to this RandomAccessible and
return the result. |
default RandomAccessibleView<T,?> |
view()
Provides a gateway for creating light-weight
views into this RandomAccessible. |
static <T,V extends RandomAccessibleView<T,V>> |
wrap(RandomAccessible<T> delegate) |
getAt, getAt, getAtRandomAccessible<T> delegate()
static <T,V extends RandomAccessibleView<T,V>> RandomAccessibleView<T,V> wrap(RandomAccessible<T> delegate)
default RandomAccessibleIntervalView<T> interval(Interval interval)
RandomAccessible.
It is the callers responsibility to ensure that the source RandomAccessible is defined in the specified interval.
For constructing an Interval from min and max coordinates, min
coordinates and dimensions, by modifying other intervals, etc, see FinalInterval and Intervals.
interval - interval boundaries.default RandomAccessibleView<T,?> slice(int d, long pos)
RandomAccessible, by fixing the d dimension of
coordinates to pos.d - coordinate dimension to fixpos - coordinate value to fix dth dimension todefault RandomAccessibleView<T,?> addDimension()
RandomAccessible, by replicating values along the added axis.
The additional dimension is the last dimension. For example, an XYZ view is created for an XY source. When accessing an XYZ sample in the view, the final coordinate is discarded and the source XY sample is accessed.
default RandomAccessibleView<T,?> translate(long... translation)
translation vector.
The pixel at coordinates x in this RandomAccessible has
coordinates (x + translation) in the resulting view.
translation - translation vectordefault RandomAccessibleView<T,?> translateInverse(long... translation)
translation vector.
The pixel at coordinates x in this RandomAccessible has
coordinates (x - translation) in the resulting view.
translation - translation vectordefault RandomAccessibleView<T,?> subsample(long... steps)
RandomAccessible. This is effectively an integer scaling
transformation.
The provided steps vector is expanded or truncated to the
dimensionality of this RandomAccessible. When expanding (steps.length < this.numDimensions()), the last element is repeated.
steps - the subsampling step sizesdefault RandomAccessibleView<T,?> rotate(int fromAxis, int toAxis)
fromAxis to toAxis.
For example, fromAxis=0, toAxis=1 means that the X axis
of this RandomAccessible is mapped to the Y axis of the
rotated view. Correspondingly, the Y axis is mapped to -X. All other axes remain unchanged. This corresponds to a 90 degree
clock-wise rotation of this RandomAccessible in the XY
plane.
fromAxis - axis indextoAxis - axis index that fromAxis should be rotated todefault RandomAccessibleView<T,?> permute(int fromAxis, int toAxis)
fromAxis to
toAxis are swapped (while all other axes remain unchanged).fromAxis - axis indextoAxis - axis index that fromAxis should be swapped withdefault RandomAccessibleView<T,?> moveAxis(int fromAxis, int toAxis)
fromAxis is
moved to index toAxis while the order of other axes is preserved.
For example, if fromAxis=2, toAxis=4 and the axis order of this
RandomAccessible is XYCZT, the resulting view will have
the axis order XYZTC.
fromAxis - axis indextoAxis - axis index that fromAxis should be moved todefault RandomAccessibleView<T,?> invertAxis(int axis)
axis with the given index.
For example, if axis=1, then coordinate (x,y,z) in the
resulting view corresponds to coordinate (x,-y,z) in this RandomAccessible.
axis - the axis to invertaxis inverteddefault RealRandomAccessibleView<T> interpolate(RandomAccessibleView.Interpolation<T> interpolation)
RealRandomAccessible view of this RandomAccessible
using interpolation with the given interpolation method.
RandomAccessibleView.Interpolation can be created by one of its static factory
methods. For example
RealRandomAccessible< IntType > interpolated =
img.view()
.extend( Extension.zero() )
.interpolate( Interpolation.lanczos() );
interpolation - the RandomAccessibleView.Interpolation methoddefault <U> RandomAccessibleView<U,?> convert(Supplier<U> targetSupplier, Converter<? super T,? super U> converter)
RandomAccessible converted to pixel type
U.
Pixel values T are converted to U using the given converter. A Converter is equivalent to a BiConsumer<T,
U> that reads a value from its first argument and writes a converted
value to its second argument.
U - target pixel typetargetSupplier - creates instances of U for storing converted valuesconverter - converts pixel values from T to Udefault <U> RandomAccessibleView<U,?> convert(Supplier<U> targetSupplier, Supplier<Converter<? super T,? super U>> converterSupplier)
RandomAccessible converted to pixel type
U.
Pixel values T are converted to U using Converters created by the given converterSupplier. A Converter is equivalent to a BiConsumer<T, U> that reads a value
from its first argument and writes a converted value to its second
argument.
U - target pixel typetargetSupplier - creates instances of U for storing converted valuesconverterSupplier - converts pixel values from T to Udefault <U> U use(Function<? super V,U> function)
function to this RandomAccessible and
return the result.U - the type of the result of the functionfunction - function to evaluate on this RandomAccessiblefunction.apply(this)default RandomAccessibleView<T,?> view()
RandomAccessibleviews into this RandomAccessible.
A view is itself a RandomAccessible or RandomAccessibleInterval whose accessors transform coordinates and/or
values on-the-fly without copying the underlying data. Consecutive
transformations are concatenated and simplified to provide optimally
efficient accessors.
Note, that accessors provided by a view are read/write. Changing pixels in a view changes the underlying image data. (Value converters are an exception.)
view in interface RandomAccessible<T>views into this RandomAccessible.default T getType()
TypedT.
It should not be assumed that the returned T instance is an
independent copy. In particular, repeated calls to getType() may
return the same instance.
default int numDimensions()
EuclideanSpacenumDimensions in interface EuclideanSpacedefault RandomAccess<T> randomAccess()
RandomAccessibleThe returned random access covers as much of the domain as possible.
Please note:RandomAccessibleIntervals have a finite domain (their Interval),
so RandomAccessible.randomAccess() is only guaranteed to cover this finite domain.
This may lead to unexpected results when using Views. In
the following code
RandomAccessible<T> extended = Views.extendBorder( img ) RandomAccessibleInterval<T> cropped = Views.interval( extended, img ); RandomAccess<T> a1 = extended.randomAccess(); RandomAccess<T> a2 = cropped.randomAccess();The
access a1 on the extended image is valid
everywhere. However, somewhat counter-intuitively, the
access a2 on the extended and cropped image
is only valid on the interval img to which the extended image was
cropped. The access is only required to cover this interval, because it
is the domain of the cropped image. Views attempts to provide the
fastest possible access that meets this requirement, and will therefore
strip the extension.
To deal with this, if you know that you need to access pixels outside the
domain of the RandomAccessibleInterval, and you know that the
RandomAccessibleInterval is actually defined beyond its interval
boundaries, then use the RandomAccessible.randomAccess(Interval) variant and
specify which interval you actually want to access. In the above example,
RandomAccess<T> a2 = cropped.randomAccess( Intervals.expand( img, 10 ) );will provide the extended access as expected.
randomAccess in interface RandomAccessible<T>default RandomAccess<T> randomAccess(Interval interval)
RandomAccessible
The returned random access is intended to be used in the specified
interval only. Thus, the RandomAccessible may provide optimized versions.
If the interval is completely contained in the domain, the random access
is guaranteed to provide the same values as that obtained by
RandomAccessible.randomAccess() within the interval.
randomAccess in interface RandomAccessible<T>interval - in which interval you intend to use the random access.Copyright © 2009–2025 ImgLib2. All rights reserved.