You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ops/doc/Concepts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
This page is designed to help *Ops users* understand the SciJava Ops concepts powering the framework.
4
4
5
5
## Ops
6
-
An **algorithm** is a mathematical routine that transforms, interrogate, or refines input values into output values. Algorithms are used throughout scientific computing, and the fundamental [purpose](Purpose.rst) of SciJava Ops is to facilitate their application.
6
+
An **algorithm** is a mathematical routine that transforms, interrogate, or refines input values into output values. Algorithms are used throughout scientific computing, and the fundamental [purpose](Purpose) of SciJava Ops is to facilitate their application.
7
7
8
8
We do that by providing a framework for consistently defining and invoking algorithm implementations as **Ops**. Ops have:
9
9
* a **name**, establishing its purpose. An Op's name describes *what* the Op does, but not *how* the Op does it.
Copy file name to clipboardExpand all lines: docs/ops/doc/ParameterConversion.rst
+48-34Lines changed: 48 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,28 @@
2
2
Parameter Conversion for Developers
3
3
========================================
4
4
5
-
In this example, we show how Ops developers can implement parameter conversion to enable seamless interoperability between Ops utilizing different data structures.between
5
+
In this example, we explain parameter conversion to a developer audience. This page provides an overview of what parameter conversion involves, how it works, and how you can enable conversion for your own data types.
6
6
7
7
Basics
8
8
======
9
9
10
-
A key :ref:`value <driving-values>` of SciJava Ops is flexibility, and flexibility is (in part) achieved through **parameter conversion**. At its core, parameter conversion allows *translation* of data stored in one data structure (e.g. an ImgLib2 ``RandomAccessibleInterval``) into a different data structure (e.g. an OpenCV ``Mat``) **on the fly**. This allows SciJava Ops to execute Ops backed by OpenCV code **on ImgLib2 data structures**.
10
+
A :ref:`value <driving-values>` of SciJava Ops is flexibility, and flexibility is (in part) achieved through **parameter conversion**. At its core, parameter conversion allows *translation* of data stored in one data structure (e.g. an ImgLib2 ``RandomAccessibleInterval``) into a different data structure (e.g. an OpenCV ``Mat``) **on the fly**. This allows SciJava Ops to execute Ops backed by OpenCV code **on ImgLib2 data structures**.
At matching time, parameter conversion is invoked when an Op matches a user request in name and in Op type, but differing in individual parameter types. In these situations, it looks for ``engine.convert`` Ops that could potentially convert the user's provided inputs into the required Op inputs, and the same, in the other direction, for the output.
15
15
16
-
A toy example
17
-
=============
16
+
.. _original-op:
18
17
19
-
Suppose we have an Op that inherently operates on ``RandomAccessibleInterval<DoubleType>``\ s:
18
+
An example ``Function``
19
+
=======================
20
+
21
+
Suppose we have a ``Function`` Op that inherently operates on ``RandomAccessibleInterval<DoubleType>``\ s:
20
22
21
23
.. code-block:: java
22
24
23
25
/**
24
-
* Conolves an image with a kernel, returning the output in a new object
26
+
* Convolves an image with a kernel, returning the output in a new object
25
27
*
26
28
* @param input the input data
27
29
* @param kernel the kernel
@@ -42,36 +44,25 @@ This Op might work well, however if users have a small kernel that is *only* use
42
44
43
45
Img<DoubleType> in =...
44
46
// 3x3 averaging kernel
45
-
double m =1/9;
46
-
double[] data =newdouble[] { //
47
-
m, m, m, //
48
-
m, m, m, //
49
-
m, m, m //
47
+
double[][] kernel = { //
48
+
{ 1/9, 1/9, 1/9}, //
49
+
{ 1/9, 1/9, 1/9}, //
50
+
{ 1/9, 1/9, 1/9} //
50
51
};
51
-
//Not ideal
52
+
//transform double[][] into a RandomAccessibleInterval
The only step for us as the developer is to tell SciJava Ops that it can convert ``double[][]``\ s to ``RandomAccessibleInterval<DoubleType>``\ s, which we do with ``engine.convert`` Ops.
63
+
In this case, users might find it nicer to specify their kernel as a ``double[][]``, which is easier for users to construct. The only step for us as the developer is to tell SciJava Ops that it can convert ``double[][]``\ s to ``RandomAccessibleInterval<DoubleType>``\ s, which we do with ``engine.convert`` Ops.
73
64
74
-
A simple ``engine.convert`` Op
65
+
An ``engine.convert`` Op
75
66
==============================
76
67
77
68
All ``engine.convert`` Ops are simple ``Function``\ s, that take as input the user argument to the Op, and return a *translation* of that data into the type expected by Ops. In our case, we want to convert *from* the user's ``double[][]`` into a ``RandomAccessibleInterval<DoubleType>``:
@@ -80,8 +71,7 @@ All ``engine.convert`` Ops are simple ``Function``\ s, that take as input the us
80
71
81
72
/**
82
73
* @param input the input data
83
-
* @return an output image whose values are equivalent to {@code input}s
84
-
* values but whose element types are {@link BitType}s.
74
+
* @return a {@link RandomAccessibleInterval}, containing the data stored in {@code input}
85
75
* @implNote op names='engine.convert', type=Function
0 commit comments