Skip to content

Commit a20b8dc

Browse files
authored
Merge pull request #133 from scijava/scijava-ops-docs/add-examples
Add examples/use case section to SciJava ops read the docs
2 parents 9cb82c9 + d379133 commit a20b8dc

File tree

6 files changed

+128
-1
lines changed

6 files changed

+128
-1
lines changed

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
9-
PROJECT ?= foo
9+
PROJECT ?= scijava-ops
1010
BUILDDIR = _build/$(PROJECT)
1111

1212
# Put it first so that "make" without argument is like "make help".

docs/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"sphinx.ext.autodoc",
1818
"sphinx.ext.viewcode",
1919
"sphinx_search.extension",
20+
"sphinx_tabs.tabs",
2021
"myst_nb",
2122
]
2223

@@ -63,3 +64,9 @@
6364
# so a file named "default.css" will overwrite the builtin "default.css".
6465
html_static_path = []
6566

67+
# Add the SciJava ops logo
68+
html_logo = "ops/images/scijava_logo.svg"
69+
html_theme_options = {
70+
"logo_only": True,
71+
"display_version": False,
72+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
=========================
2+
Gaussian blur subtraction
3+
=========================
4+
5+
In this example we will use SciJava Ops to open an image, apply a guassian blur and subract the blurred image from the input image.
6+
This technique can be used to extract features, such as puncta, from a noisy background.
7+
8+
SciJava Ops via Fiji's sripting engine with `script parameters`_:
9+
10+
.. tabs::
11+
12+
.. code-tab:: groovy
13+
14+
#@ ImgPlus img
15+
#@ Double (label="Sigma:", value=5.0) sigma
16+
#@output ImgPlus result
17+
18+
import org.scijava.ops.api.OpEnvironment
19+
import net.imglib2.type.numeric.real.FloatType
20+
21+
// build the Ops environment
22+
ops = OpEnvironment.build();
23+
24+
// convert input ImgPlus image to float32
25+
img = ops.op("convert.float32").arity1().input(img).apply();
26+
27+
// create gaussian blurred image
28+
img_gauss = ops.op("filter.gauss").arity2().input(img, sigma).apply();
29+
30+
// subtract the input and blurred images
31+
result = ops.op("create.img").arity2().input(img, new FloatType()).apply();
32+
ops.op("math.sub").arity2().input(img, img_gauss).output(result).compute();
33+
34+
.. code-tab:: python
35+
36+
#@ ImgPlus img
37+
#@ Double (label="Sigma:", value=5.0) sigma
38+
#@output ImgPlus result
39+
40+
from org.scijava.ops.api import OpEnvironment
41+
from net.imglib2.type.numeric.real import FloatType
42+
43+
# build the Ops environment
44+
ops = OpEnvironment.build()
45+
46+
# convert input ImgPlus image to float32
47+
img = ops.op("convert.float32").arity1().input(img).apply()
48+
49+
# create gaussian blurred image
50+
img_gauss = ops.op("filter.gauss").arity2().input(img, sigma).apply()
51+
52+
# subtract the input and blurred images
53+
result = ops.op("create.img").arity2().input(img, FloatType()).apply()
54+
ops.op("math.sub").arity2().input(img, img_gauss).output(result).compute()
55+
56+
.. _`script parameters`: https://imagej.net/scripting/parameters

docs/ops/doc/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ The combination of these libraries allows declarative image analysis workflows,
2525
ScriptingInImageJ2
2626
Benchmarks
2727

28+
.. toctree::
29+
:maxdepth: 2
30+
:caption: ⚙️ Examples
31+
32+
examples/example_gaussian_subtraction
33+
2834
.. toctree::
2935
:maxdepth: 2
3036
:caption: 🛠️ Development

docs/ops/images/scijava_logo.svg

Lines changed: 57 additions & 0 deletions
Loading

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx-multiproject
22
sphinx_rtd_theme
3+
sphinx-tabs
34
myst-nb
45
readthedocs-sphinx-search

0 commit comments

Comments
 (0)