The first two commits are cosmetic changes that can be ignored.
The second commit updates the IFunction interface with 3 new methods, all called view. These methods return an IterableRandomAccessibleFunction, which is both an IterableInterval and a RandomAccessible, and also a View given that its data should be cached when planning to do multiple accesses on the same positions. When iterating its data with IterableRandomAccessibleFunction.cursor() or IterableRandomAccessibleFunction.randomAccess(), the computation described by the IFunction is done on the fly, returning the result as the numeric content of the RealType outputType. Underlying the cursor and randomAccess methods are the corresponding methods in the Compute class, which does the validation of operations and included images.
The 3 new view methods of IFunction are:
view(), returning a View (an IterableRandomAccessibleFunction) of the same Type as the first RandomAccessibleInterval found wrapped in the IFunction and its nested IFunction instances, if any.
view(RealType outputType), like above but specifies the RealType to use for the computations, as well as for the return value RealType. An implict generic Converter uses RealType.setReal(RealType.getRealDouble()) for the conversion from input to output.
view(RealType outputType, Converter converter), where a explicit Converter mediates the transformation from any RealType subclass in the input "images" (RandomAccessibleInterval) wrapped in the IFunction.
In other words, the view methods enable code such as:
from net.imglib2.algorithm.math.ImgMath import add
from net.imglib2.view import Views
from net.imglib2.img.array import ArrayImgs
img = ArrayImgs.unsignedBytes([100, 100, 100])
# See the input img with the pixels within the specified ROI having their values + 100:
region = Views.interval( add(img, 100).view(), [20, 20, 20], [39, 39, 39] )
... without altering the original img image in anyway.
Before, one had to copy the result of the computation into a new image in order to see it.
Along with the changes in the IFunction interface, there're several related changes in e.g. OFunction (new children() method to collect nested OFunction instances), and to ease the implementation, most classes implementing IFunction also extend ViewableFunction, an abstract class that implements these 3 methods.
The IFunction subclasses NumberSource and Var do not extend ViewableFunction and their view methods throw UnsupportedOperationException. These two classes represent single values. If an IFunction is constructed to compute using only NumberSource and Var, invoking view will throw an Exception.
The first two commits are cosmetic changes that can be ignored.
The second commit updates the
IFunction
interface with 3 new methods, all calledview
. These methods return anIterableRandomAccessibleFunction
, which is both anIterableInterval
and aRandomAccessible
, and also aView
given that its data should be cached when planning to do multiple accesses on the same positions. When iterating its data withIterableRandomAccessibleFunction.cursor()
orIterableRandomAccessibleFunction.randomAccess()
, the computation described by theIFunction
is done on the fly, returning the result as the numeric content of theRealType outputType
. Underlying thecursor
andrandomAccess
methods are the corresponding methods in theCompute
class, which does the validation of operations and included images.The 3 new
view
methods ofIFunction
are:view()
, returning aView
(anIterableRandomAccessibleFunction
) of the sameType
as the firstRandomAccessibleInterval
found wrapped in theIFunction
and its nestedIFunction
instances, if any.view(RealType outputType)
, like above but specifies theRealType
to use for the computations, as well as for the return valueRealType
. An implict genericConverter
usesRealType.setReal(RealType.getRealDouble())
for the conversion from input to output.view(RealType outputType, Converter converter)
, where a explicitConverter
mediates the transformation from anyRealType
subclass in the input "images" (RandomAccessibleInterval
) wrapped in theIFunction
.In other words, the
view
methods enable code such as:... without altering the original
img
image in anyway.Before, one had to copy the result of the computation into a new image in order to see it.
Along with the changes in the
IFunction
interface, there're several related changes in e.g.OFunction
(newchildren()
method to collect nestedOFunction
instances), and to ease the implementation, most classes implementingIFunction
also extendViewableFunction
, an abstract class that implements these 3 methods.The
IFunction
subclassesNumberSource
andVar
do not extendViewableFunction
and theirview
methods throwUnsupportedOperationException
. These two classes represent single values. If anIFunction
is constructed to compute using onlyNumberSource
andVar
, invokingview
will throw anException
.