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
{{ message }}
Repository navigation
Commit bab193d
Browse filesBrowse the repository at this point in the historyBrowse files
Using SciJava Ops within scripts unlocks the most powerful aspects of Ops. The following page will explain how you can write a script in Fiji's Script Editor that utilizes Ops for image processing.
3
+
Scripts provide a simple, familiar interface for accessing SciJava Ops and allows combination with additional resources for image processing and beyond. The following page will explain how you can write a script in Fiji's [Script Editor](https://imagej.net/scripting/) that utilizes Ops for image processing.
4
4
5
5
## Obtaining an OpEnvironment
6
6
7
-
To run Ops, scripts require an `OpEnvironment`. The easiest way to obtain an `OpEnvironment` with all available Ops is to declare an `OpEnvironment` as a script parameter:
7
+
To run Ops we always start with an `OpEnvironment`. The easiest way to obtain an `OpEnvironment` with all available Ops is to declare an `OpEnvironment` as a [script parameter](https://imagej.net/scripting/parameters):
8
8
9
9
```text
10
10
#@ OpEnvironment ops
11
11
```
12
12
13
-
## Obtaining inputs
13
+
## Setting inputs and outputs
14
14
15
-
Scripts using SciJava Ops obtain inputs like any other SciJava script, and the lines below will provide us with an `Img` input parameter and an `Img` output parameter.
15
+
A good starting point is to declare script parameters that match your desired Op's parameters. When performing image processing we are modifying an existing image, so we also want to create an output image in the script so our result will be shown. The following lines use SciJava's script parameters to obtain the active image as an input along with a user-defined sigma, while establishing our output.
16
16
17
17
```text
18
18
#@ Img imgInput
19
+
#@ Double sigma
19
20
#@output Img out
20
21
```
21
22
22
-
For more information on SciJava scripting parameters, please visit [this page](https://imagej.net/scripting/parameters).
23
-
24
23
## Calling Ops
25
24
26
-
The OpBuilder syntax should be used to retrieve and execute Ops from the `OpEnvironment`. The following line executes a Gaussian Blur on an input image using a `filter.gauss` Op:
25
+
The [OpBuilder syntax](CallingOps) should be used to retrieve and execute Ops from the `OpEnvironment`. The following line executes a Gaussian Blur on an input image using a `filter.gauss` Op:
27
26
```text
28
-
out = ops.op("filter.gauss").input(imgInput, new Double(3.0)).apply()
27
+
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
29
28
```
30
29
31
30
## Putting it all together
@@ -35,10 +34,19 @@ The below script can be pasted into the Script Editor. **Ensure that the Script
35
34
```text
36
35
#@ OpEnvironment ops
37
36
#@ Img imgInput
37
+
#@ Double sigma
38
38
#@output Img out
39
39
40
-
// Call some Ops!
41
-
out = ops.op("filter.gauss").input(imgInput, new Double(3.0)).apply()
40
+
// Call our Op!
41
+
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
42
42
```
43
43
44
-
Scripting in Fiji is a convenient gateway to accessing SciJava Ops. To see more, check out some examples, such as [image deconvolution](examples/deconvolution.rst) or [FLIM analysis](examples/flim_analysis.rst)!
44
+
## Add your Op to the menu
45
+
46
+
If you want to re-use an Op outside of the script editor: good news! All SciJava scripts are ImageJ plugins and can be [installed](https://imagej.net/plugins/index#installing-plugins-manually) into your Fiji installation. For example, if we create a new `Ops` folder in our `Fiji.app/plugins/` directory and save our script there as `FilterGauss_.groovy` (or similar - just don't forget the `_`!) then after re-starting Fiji we can run our Op from the `Plugins > Ops` menu, and it will also show up in the [search bar](https://imagej.net/learn/#the-search-bar).
47
+
48
+
## Next steps
49
+
50
+
Check out the How-To Guides for important information like how to [explore the available Ops](SearchingForOps).
51
+
52
+
Check out some examples such as [image deconvolution](examples/deconvolution.rst) or [FLIM analysis](examples/flim_analysis.rst) to see more complete cases of Ops being used in the Script editor!
0 commit comments