Scripting in Fiji
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 that utilizes Ops for image processing.
Obtaining an OpEnvironment
To run Ops we always start with an OpEnvironment
. Within Fiji, the easiest way to obtain an OpEnvironment
is to declare it as a script parameter:
#@ OpEnvironment ops
Setting inputs and outputs
A good starting point is to declare script parameters that match your desired Op’s parameters. When performing image processing, we are operating on an existing image; we also want to create an output image in the script so that our result will be shown. The following lines use SciJava script parameters to obtain the active image as an input along with a user-defined sigma, while establishing our output.
#@ Img imgInput
#@ Double sigma
#@output Img out
Calling Ops
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:
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
Putting it all together
The below script can be pasted into the Script Editor. Ensure that the Script Editor is configured to run a Groovy script (Language → Groovy in the Script Editor menu).
#@ OpEnvironment ops
#@ Img imgInput
#@ Double sigma
#@output Img out
// Call our Op!
out = ops.op("filter.gauss").input(imgInput, sigma).apply()
Next steps
Check out the How-To Guides for important information like how to explore the available Ops.
Check out some examples such as image deconvolution or FLIM analysis to see more complete cases of Ops being used in the Script Editor!