- java.lang.Object
-
- org.scijava.ops.tutorial.OpConversion
-
public class OpConversion extends Object
One powerful feature of SciJava Ops is the ability to transform individual Ops to match user requests. In this way, SciJava Ops can satisfy many Op calls with just one implementation. The simplest type of transformation is showcased inOpAdaptation.A more complex transformation, termed parameter "conversion", alters individual Op parameter types. Parameter conversion makes use of two different Op types:
engine.convertOps transform user inputs into a different data typeengine.copyOps propagate changes to mutable Op parameters back into the user's output buffers.
Conversion can be used to call an Op using parameters of completely different types. This can be as simple as using an Integer instead of a Double, or go beyond Java type assignment rules with custom defined type conversion (e.g. images from one library to another). When this happens, the following steps are taken:
- All inputs are converted to types required by the Op, using
engine.convert"preconverter" Ops. - The Op is invoked on the converted inputs
- If the Op defines a pure output object, that output is converted
to the user's requested type using a
engine.convert"postconverter" Op - If the Op defines a mutable output object (i.e. a pre-allocated
output buffer), the converted pre-allocated output buffer is copied back into
the user's pre-allocated output buffer using a
engine.copyOp.
Below, we can see how this works by calling the below Field Op, implemented for
Doubles, withIntegerarguments
-
-
Constructor Summary
Constructors Constructor Description OpConversion()
-
-
-
Field Detail
-
fieldOp
public final BiFunction<Double,Double,Double> fieldOp
A simple Op, written as aField, that performs a simple calculation.- Output parameters:
a- linear combination of {@code a} and {@code b}- Input parameters:
a- the first {@link Double}b- the second {@link Double}- Implementation Note:
- op names="tutorial.conversion"
-
-
Method Detail
-
main
public static void main(String... args)
-
-