CINXE.COM
JRuby Scripting
<!DOCTYPE html> <html> <head> <title>JRuby Scripting</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3" /> <meta content="ImageJ Wiki" property="og:site_name"> <meta content="JRuby Scripting" property="og:title"> <meta content="article" property="og:type"> <meta content="The ImageJ wiki is a community-edited knowledge base on topics relating to ImageJ, a public domain program for processing and analyzing scientific images, and its ecosystem of derivatives and variants, including ImageJ2, Fiji, and others." property="og:description"> <meta content="https://imagej.github.io/scripting/jruby" property="og:url"> <meta content="https://imagej.github.io/media/icons/imagej2.png" property="og:image"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="manifest" href="/site.webmanifest"> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> <meta name="msapplication-TileColor" content="#da532c"> <meta name="theme-color" content="#ffffff"> <link rel="stylesheet" href="/assets/css/lightbox.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/algolia-min.css"/> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/dygraphs@2.1.0/dist/dygraph.min.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dygraphs@2.1.0/dist/dygraph.min.css" /> <link rel="stylesheet" href="/assets/css/main.css" /> <link rel="stylesheet" href="/assets/css/layout.css"/> <link rel="stylesheet" href="/assets/css/includes.css" /> <link rel="stylesheet" href="/assets/css/dock.css"/> <noscript><link rel="stylesheet" href="/assets/css/noscript.css" /></noscript> <link rel="stylesheet" href="/assets/css/page.css" /> </head> <body class="is-preload"> <!-- Top bar --> <section id="top-bar"> <a href="/"><img id="site-logo" src="/media/icons/imagej2.png"></a> <div id="search-panel"> <div id="search-box"></div> </div> </section> <!-- Page-info --> <div class="page-info"> <a href="https://github.com/imagej/imagej.github.io/commits/main/_pages/scripting/jruby.md">Page history</a> <a href="https://github.com/imagej/imagej.github.io/edit/main/_pages/scripting/jruby.md">Edit this page</a> <a href="/editing">How do I edit this website?</a></div> <section id="left-column" class="sidebar dock"> <!-- Menu --> <div class="menu dockable"> <div class="drag-handle"></div><h3>ImageJ Docs</h3> <ul> <li><a href="/downloads">Download</a></li> <li><details><summary>Learn</summary><ul> <li><details><summary><a href="/learn">ImageJ Basics</a></summary><ul> <li><a href="/tutorials">Tutorials</a></li> <li><a href="/learn/user-guides">User Guides</a></li> <li><a href="/learn/keyboard-shortcuts">Keyboard Shortcuts</a></li> <li><a href="/learn/tips-and-tricks">Tips and Tricks</a></li> <li><a href="/learn/troubleshooting">Troubleshooting</a></li> <li><a href="/learn/faq">Frequently Asked Questions</a></li> <li><details><summary><a href="/platforms">Supported Platforms</a></summary><ul> <li><a href="/platforms/windows">Windows</a></li> <li><a href="/platforms/macos">MacOS</a></li> <li><a href="/platforms/linux">Linux</a></li> <li><a href="/platforms/pi">Raspberry Pi</a></li> <li><a href="/platforms/android">Android</a></li> </ul></details></li> <!-- Learn/ImageJ Basics/Supported Platforms --> <li><details><summary><a href="/formats">File Formats</a></summary><ul> <li><a href="/formats/bio-formats">Bio-Formats</a></li> <li><a href="/formats/video">Video formats</a></li> <li><a href="/formats/quicktime">QuickTime</a></li> <li><a href="/formats/tiff">TIFF</a></li> <li><a href="/formats/pdf">PDF</a></li> <li><a href="/formats/dicom">DICOM</a></li> <li><a href="/formats/lsm">Zeiss LSM</a></li> <li><a href="/formats/olympus">Olympus VSI</a></li> <li><a href="/formats/lurawave">Opera Flex</a></li> <li><a href="/formats/fib-sem">FIB-SEM</a></li> </ul></details></li> <!-- Learn/ImageJ Basics/File Formats --> </ul></details></li> <!-- Learn/ImageJ --> <li><details><summary><a href="/imaging">Scientific Imaging</a></summary><ul> <li><a href="/imaging/principles">Principles of Scientific Imaging</a></li> <li><a href="/imaging/annotating-images">Annotating Images</a></li> <li><a href="/imaging/colocalization-analysis">Colocalization</a></li> <li><a href="/imaging/color-image-processing">Color Image Processing</a></li> <li><a href="/imaging/deconvolution">Deconvolution</a></li> <li><a href="/imaging/image-intensity-processing">Image Intensity Processing</a></li> <li><a href="/imaging/particle-analysis">Particle Analysis</a></li> <li><a href="/imaging/registration">Registration</a></li> <li><a href="/imaging/segmentation">Segmentation</a></li> <li><a href="/imaging/stack-slice-manipulations">Stack-slice Manipulations</a></li> <li><a href="/imaging/t-functions">T-functions</a></li> <li><a href="/imaging/tracking">Tracking</a></li> <li><a href="/imaging/visualization">Visualization</a></li> <li><a href="/imaging/z-functions">Z-functions</a></li> </ul></details></li> <!-- Learn/Scientific Imaging --> </ul></details></li> <!-- Learn --> <li><details open><summary><a href="/plugins">Extend</a></summary><ul> <li><a href="/list-of-extensions">List of Extensions</a></li> <li><details><summary><a href="/update-sites">Update Sites</a></summary><ul> <li><a href="/list-of-update-sites">List of Update Sites</a></li> <li><a href="/update-sites/following">Following an Update Site</a></li> <li><a href="/update-sites/setup">Creating an Update Site</a></li> <li><a href="/update-sites/tos">Terms of Service</a></li> <li><a href="/update-sites/automatic-uploads">Automatic Upload</a></li> <li><a href="/update-sites/core-uploads">Uploading to Core Sites</a></li> <li><a href="/update-sites/faq">Update Sites FAQ</a></li> <li><a href="/update-sites/stats">Statistics</a></li> </ul></details></li> <!-- Extend/Update Sites --> <li><details open><summary><a href="/scripting">Scripting</a></summary><ul> <li><a href="/scripting/basics">Scripting Basics</a></li> <li><a href="/scripting/script-editor">Script Editor</a></li> <li><a href="/scripting/parameters">Parameters</a></li> <li><a href="/scripting/user-input">User Input</a></li> <li><a href="/scripting/auto-imports">Auto Import</a></li> <li><a href="/scripting/templates">Templates</a></li> <li><a href="/scripting/batch">Batch Processing</a></li> <li><a href="/scripting/headless">Running Headlessly</a></li> <li><a href="/scripting/comparisons">Scripting Comparisons</a></li> <li><a href="/scripting/toolbox">Toolbox</a></li> <li><details open><summary>Languages</summary><ul> <li><a href="/scripting/beanshell">BeanShell Scripting</a></li> <li><a href="/scripting/groovy">Groovy Scripting</a></li> <li><a href="/scripting/macro">ImageJ Macro</a></li> <li><a href="/scripting/javascript">JavaScript</a></li> <li><a href="/scripting/clojure">Lisp (Clojure)</a></li> <li><a href="/scripting/matlab">MATLAB</a></li> <li><a href="/scripting/jython">Python (Jython)</a></li> <li><a href="/scripting/python">Python (native)</a></li> <li><a href="/scripting/renjin">R (Renjin)</a></li> <li><a class="current-page">Ruby (JRuby)</a></li> <li><a href="/scripting/scala">Scala Scripting</a></li> </ul></details></li> <!-- Extend/Scripting/Languages --> </ul></details></li> <!-- Extend/Scripting --> <li><details><summary><a href="/develop">Development</a></summary><ul> <li><a href="/develop/philosophy">Philosophy</a></li> <li><a href="/develop/architecture">Architecture</a></li> <li><a href="/develop/source">Source code</a></li> <li><a href="/develop/project-management">Project management</a></li> <li><a href="/develop/coding-style">Coding style</a></li> <li><a href="/develop/javadoc">Using Javadoc</a></li> <li><a href="/develop/debugging">Debugging</a></li> <li><a href="/develop/wish-list">Wish list</a></li> <li><details><summary>Tools</summary><ul> <li><a href="/develop/github">GitHub</a></li> <li><a href="/develop/maven">Maven</a></li> <li><a href="/develop/ci">CI/CD</a></li> <li><a href="/develop/dotfiles">Dotfiles</a></li> <li><details><summary><a href="/develop/ides">IDEs</a></summary><ul> <li><a href="/develop/eclipse">Eclipse</a></li> <li><a href="/develop/netbeans">NetBeans</a></li> <li><a href="/develop/intellij">IntelliJ IDEA</a></li> <li><a href="/develop/command-line">Command Line</a></li> </ul></details></li> </ul></details></li> <!-- Extend/Development/Tools --> <li><details><summary>Guides</summary><ul> <li><a href="/develop/plugins">Writing plugins</a></li> <li><a href="/develop/improving-the-code">Contributing to a plugin</a></li> <li><a href="/develop/releasing">Development lifecycle</a></li> <li><a href="/develop/building-a-pom">Building a POM</a></li> <li><a href="/develop/debugging-exercises">Hands-on debugging</a></li> <li><a href="/develop/writing-ops">Adding new ops</a></li> <li><a href="/develop/formats">Adding new formats</a></li> <li><a href="/develop/native-libraries">Using native libraries</a></li> <li><a href="/develop/tips">Tips for developers</a></li> <li><a href="/develop/cpp-tips">Tips for C++ developers</a></li> <li><a href="/develop/ij1-plugins">ImageJ 1.x plugins</a></li> <li><a href="/develop/versioning">Versioning</a></li> <li><a href="/develop/logging">Logging</a></li> <li><a href="/develop/uber-jars">Uber-JARs</a></li> </ul></details></li> <!-- Extend/Development/Guides --> <li><details><summary><a href="/develop/git">Git</a></summary><ul> <li><a href="/develop/git/eclipse">Git in Eclipse (EGit)</a></li> <li><a href="/develop/git/mini-howto">Git mini howto</a></li> <li><a href="/develop/git/workshop">Git workshop</a></li> <li><a href="/develop/git/conflicts">Git conflicts</a></li> <li><a href="/develop/git/topic-branches">Git topic branches</a></li> <li><a href="/develop/git/notes">Git notes</a></li> <li><a href="/develop/git/reflogs">Git reflogs</a></li> <li><a href="/develop/git/submodules">Git submodules</a></li> <li><a href="/develop/git/pinpoint-regressions">How to pinpoint regressions</a></li> <li><a href="/develop/git/publish-a-repository">How to publish a git repository</a></li> <li><a href="/develop/git/extract-a-subproject">How to extract a subproject</a></li> </ul></details></li> <!-- Extend/Development/Git --> </ul></details></li> <!-- Extend/Development --> </ul></details></li> <!-- Extend --> <li><details><summary><a href="/contribute">Contribute</a></summary><ul> <li><a href="/contribute/citing">Citing</a></li> <li><a href="/people">Contributors</a></li> <li><a href="/orgs">Organizations</a></li> <li><a href="/contribute/governance">Governance</a></li> <li><a href="/contribute/funding">Funding</a></li> <li><a href="/contribute/fiji">Contributing to Fiji</a></li> <li><details><summary><a href="/licensing">Licensing</a></summary><ul> <li><details><summary><a href="/licensing/open-source">Open Source</a></summary><ul> <li><a href="/licensing/apache">Apache</a></li> <li><a href="/licensing/bsd">BSD</a></li> <li><a href="/licensing/epl">EPL</a></li> <li><a href="/licensing/gpl">GPL</a></li> <li><a href="/licensing/lgpl">LGPL</a></li> <li><a href="/licensing/mit">MIT</a></li> <li><a href="/licensing/public-domain">Public domain</a></li> <li><a href="/licensing/big">BIG</a></li> </ul></details></li> <!-- Contribute/Licensing/Open Source --> <li><a href="/licensing/closed-source">Proprietary</a></li> </ul></details></li> <!-- Contribute/Licensing --> <li><details><summary><a href="/editing">Editing the Wiki</a></summary><ul> <li><a href="/editing/advanced">Advanced Editing</a></li> <li><a href="/editing/buttons">Buttons</a></li> <li><a href="/editing/citations">Citations</a></li> <li><a href="/editing/code">Source Code</a></li> <li><a href="/editing/debugging">Debugging</a></li> <li><a href="/editing/headers">Headers</a></li> <li><a href="/editing/icons">Icons</a></li> <li><a href="/editing/images">Images</a></li> <li><a href="/editing/keys">Keyboard Shortcuts</a></li> <li><a href="/editing/linking">Linking</a></li> <li><a href="/editing/math">Math Expressions</a></li> <li><a href="/editing/menu-paths">Menu Paths</a></li> <li><a href="/editing/navigation">Navigation</a></li> <li><a href="/editing/notices">Notices</a></li> <li><a href="/editing/people">People</a></li> <li><a href="/editing/pitfalls">Pitfalls</a></li> <li><a href="/editing/quizzes">Quizzes</a></li> <li><a href="/editing/statbox">Statbox</a></li> <li><a href="/editing/symbols">Symbols</a></li> <li><a href="/editing/tables">Tables</a></li> <li><a href="/editing/tooltips">Tooltips</a></li> <li><a href="/editing/videos">Videos</a></li> <li><a href="/editing/whitespace">Whitespace</a></li> </ul></details></li> <!-- Contribute/Editing the Wiki --> </ul></details></li> <!-- Contribute --> <li><details><summary><a href="/discuss">Discuss</a></summary><ul> <li><a href="/discuss/bugs">Reporting Issues</a></li> <li><a href="/discuss/mailing-lists">Mailing Lists</a></li> <li><a href="/discuss/chat">Chat</a></li> </ul></details></li> <!-- Discuss --> <li><details><summary>Explore</summary><ul> <li><a href="/news">News</a></li> <li><details><summary><a href="/events">Events</a></summary><ul> <li><a href="/events/presentations">Presentations</a></li> <li><a href="/events/conferences">Conferences</a></li> <li><a href="/events/hackathons">Hackathons</a></li> <li><a href="/events">More...</a></li> </ul></details></li> <!-- Discuss/Events --> <li><details><summary><a href="/libs">Libraries</a></summary><ul> <li><a href="/libs/imagej-ops">ImageJ Ops</a></li> <li><a href="/libs/imagej-common">ImageJ Common</a></li> <li><a href="/libs/imagej-legacy">ImageJ Legacy</a></li> <li><a href="/libs/scijava">SciJava</a></li> <li><a href="/libs/scifio">SCIFIO</a></li> <li><details><summary><a href="/libs/imglib2">ImgLib2</a></summary><ul> <li><a href="/libs/imglib2/getting-started">Getting Started</a></li> <li><a href="/libs/imglib2/accessors">Accessors</a></li> <li><a href="/libs/imglib2/accessibles">Accessibles</a></li> <li><a href="/libs/imglib2/examples">Examples</a></li> <li><a href="/libs/imglib2/workshop-introductory">Introductory Workshop</a></li> <li><a href="/libs/imglib2/workshop-advanced">Advanced Workshop</a></li> <li><a href="/libs/imglib2/matlab">ImgLib2 images in MATLAB</a></li> <li><a href="/libs/imglib2/benchmarks">Benchmarks</a></li> <li><a href="/libs/imglib2/faq">FAQ</a></li> <li><a href="/libs/imglib2/developing">Developing ImgLib2</a></li> <li><a href="/libs/imglib2/discussion">ImgLib2 Discussion</a></li> </ul></details></li> <!-- Explore/Libraries/ImgLib2 --> <li><a href="/libs">More...</a></li> </ul></details></li> <!-- Explore/Libraries --> <li><details><summary><a href="/software">Software</a></summary><ul> <li><a href="/software/nih-image">NIH Image</a></li> <li><a href="/software/imagej">ImageJ</a></li> <li><a href="/software/imagej2">ImageJ2</a></li> <li><a href="/software/fiji">Fiji</a></li> <li><a href="/software">More...</a></li> </ul></details></li> <!-- Explore/Software --> </ul></details></li> <!-- Explore --> </ul> </div> </section> <section id="right-column" class="sidebar dock"> <!-- Vital stats --> <!-- Table of contents --> <div id="toc" class="toc menu dockable"> <div class="drag-handle"></div> <h3>Page contents</h3> <ul data-toc="#content" data-toc-headings="h1,h2,h3,h4,h5,h6"></ul> </div> </section> <!-- Page title --> <div class="container"> <header class="major special"> <a class="project-icon shadowed-box" href="/software/imagej"><span class="tooltip"><img src="/media/icons/imagej.png"><span class="tooltiptext" style="top: 80%; left: 25%; width: 20em">This page describes content relating to the original version of ImageJ. Click the logo for details.</span></span></a> <h1>JRuby Scripting</h1> <span class="project-counterweight"> </span> </header> </div> <!-- Nav bar --> <!-- Main content --> <section id="page" class="main style1"> <div class="container"> <div class="box alt"></div> <div id="content" class="page-content"> <p><a href="http://jruby.codehaus.org/">JRuby</a> is a marvellous project that created a complete implementation of Ruby that runs in the JVM. The excellent work of the authors of JRuby has made it very simple for us to add JRuby scripting into ImageJ.</p> <p>JRuby scripting in ImageJ is a nice alternative to scripting using ImageJ’s <a href="/scripting/macro">macro language</a>. It has the following advantages:</p> <ul> <li>You don’t have to learn a new language to script ImageJ (assuming you know Ruby)</li> <li>You’re not limited to using the functionality exposed by the macro language: you can use any class in ImageJ, one of its plugins or standard Java classes</li> <li>Developing JRuby scripts is very fast compared to developing plugins in Java</li> </ul> <div class="notice" style="font-size: 2; background: #ebf2f8; border-left: 10px solid #67a1fe"><div class="notice-icon"><img src="/media/icons/info.svg" width="32" /></div><div class="notice-content"><p>These advantages, of course, are shared by all the scripting languages available in <a href="/software/imagej2">ImageJ2</a>, including <a href="/scripting/jython">Jython</a>, <a href="/scripting/clojure">Clojure</a>, <a href="/scripting/beanshell">BeanShell</a> and <a href="/scripting/javascript">JavaScript</a>.</p> </div> </div> <p>If you have any questions or suggestions about JRuby scripting in ImageJ, please contact the <a href="https://forum.image.sc/">Image.sc Forum</a>. Have fun!</p> <h2 id="tutorial">Tutorial</h2> <p>Let’s start writing some JRuby right away—start up the interpreter by going to <span class="bc"><span>Plugins</span> › <span>Scripting</span> › <span>JRuby Interpreter</span></span>. The interpreter window will pop up, but it may take a little time for the JRuby runtime to be ready. You should initially see the message:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Starting JRuby ... </code></pre></div></div> <p>… and when it’s ready, the line:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Done. </code></pre></div></div> <p>Now you can start typing Ruby expressions into that window, such as:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="s2">"hello there"</span><span class="p">.</span><span class="nf">upcase</span><span class="p">[</span><span class="mi">1</span><span class="o">..</span><span class="mi">4</span><span class="p">]</span> <span class="no">ELLO</span> </code></pre></div></div> <p>It would be a good idea to take a quick look at the page on <a href="/scripting">Scripting Help</a> for tips on using this interpreter window.l</p> <p>Try loading one of the ImageJ sample images by going to <span class="bc"><span>File</span> › <span>Open Samples</span> › <span>T1 Head (2.4M, 16-bits)</span></span>. Once you’ve done that we’ll examine the image using JRuby. You can get a reference to the current image with ij.IJ.getImage. Try assigning the result to a variable, like this:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">i</span> <span class="o">=</span> <span class="n">ij</span><span class="o">.</span><span class="no">IJ</span><span class="p">.</span><span class="nf">getImage</span> <span class="n">imp</span><span class="p">[</span><span class="n">t1</span><span class="o">-</span><span class="n">head</span><span class="p">.</span><span class="nf">tif</span> <span class="mi">256</span><span class="n">x256x129</span><span class="p">]</span> </code></pre></div></div> <p>Now we can find out the width and the depth of the stack like this:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">w</span> <span class="o">=</span> <span class="n">i</span><span class="p">.</span><span class="nf">getWidth</span> <span class="mi">256</span> <span class="o">>>></span> <span class="n">d</span> <span class="o">=</span> <span class="n">i</span><span class="p">.</span><span class="nf">getStackSize</span> <span class="mi">129</span> </code></pre></div></div> <p>Many of the operations that you might want to perform on the image are available via the ImageProcessor associate with a slice. For example, to invert the current slice do:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">i</span><span class="p">.</span><span class="nf">getProcessor</span><span class="p">.</span><span class="nf">invert</span> </code></pre></div></div> <p>That won’t actually produce a visible effect on the image until you also call <code class="language-plaintext highlighter-rouge">i.updateAndDraw</code> on the image:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>i.updateAndDraw </code></pre></div></div> <p>If you scroll through the stack now you should find that one of the slices is inverted.</p> <h3 id="note-on-names">Note On Names</h3> <p>You might find the use of <code class="language-plaintext highlighter-rouge">ij.IJ.getImage</code> above slightly suspicious if you’re used to Java and the ImageJ API. <code class="language-plaintext highlighter-rouge">ij</code> is the Java package name, <code class="language-plaintext highlighter-rouge">IJ</code> is the class name in that package and <code class="language-plaintext highlighter-rouge">getImage</code> is a static method in that class which returns a reference to an ImagePlus object representing the current image or null if there is none. How does this work? We have set up the JRuby interpreter in ImageJ so that if a method or class name can’t be found it will look for a correponding class or method name in the <code class="language-plaintext highlighter-rouge">ij.*</code> packages. JRuby by default does exactly this for the <code class="language-plaintext highlighter-rouge">java.*</code> classes, so for example the following works without having to explicitly include the <code class="language-plaintext highlighter-rouge">java.util.Random</code> class:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">rng</span> <span class="o">=</span> <span class="n">java</span><span class="p">.</span><span class="nf">util</span><span class="o">.</span><span class="no">Random</span><span class="p">.</span><span class="nf">new</span> <span class="n">java</span><span class="p">.</span><span class="nf">util</span><span class="o">.</span><span class="no">Random</span><span class="vi">@bf9a12</span> <span class="o">>>></span> <span class="n">rng</span><span class="p">.</span><span class="nf">nextInt</span> <span class="mi">1024</span> <span class="mi">603</span> <span class="o">>>></span> <span class="n">rng</span><span class="p">.</span><span class="nf">nextInt</span> <span class="mi">1024</span> <span class="mi">94</span> </code></pre></div></div> <p>Note that this is an example of creating an object in JRuby; you use the usual <code class="language-plaintext highlighter-rouge">Something.new</code> syntax of Ruby, but it creates an object of the standard Java class. Hopefully you’re thinking “Excellent!” or something similar at this stage…</p> <h3 id="importing-classes">Importing classes</h3> <p>If you need to use classes that aren’t in the <code class="language-plaintext highlighter-rouge">java.*</code> or <code class="language-plaintext highlighter-rouge">ij.*</code> hierarchy—or if you are developing JRuby scripts in the <a href="/scripting/script-editor">Script Editor</a> of <a href="/software/imagej2">ImageJ2</a>—you will have to include them explicitly.To reference Java classes from JRuby you will need to import them. <br /></p> <div class="notice" style="font-size: 2; background: #e6e6e6; border-left: 10px solid #fadd8d"><div class="notice-icon"><img src="/media/icons/imagej2.png" /></div><div class="notice-content"><p>Unlike the original <a href="/software/imagej">ImageJ</a>, <a href="/software/imagej2">ImageJ2</a> (and therefore <a href="/software/fiji">Fiji</a>) does not automatically import any classes. Consequently, scripts written for ImageJ will not run in ImageJ2 without adding the proper imports. The rationale is that the auto-import feature is not safe. What if two classes of the same name live in two different packages? Or if a new class is introduced that makes formerly unique names ambiguous? All of a sudden, all of the scripts that reference the original class no longer work. In short: auto-imports are dangerously imprecise.</p> </div> </div> <p><br />For example, in the classpath of <a href="/software/fiji">Fiji</a> there is a useful class called <code class="language-plaintext highlighter-rouge">util.BatchOpener,</code> that has static methods for opening files as arrays of <code class="language-plaintext highlighter-rouge">ImagePlus</code> objects (one per channel) without showing them. To use these methods, you would have to do:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">java_import</span> <span class="s1">'util.BatchOpener'</span> <span class="n">util</span><span class="o">.</span><span class="no">BatchOpener</span> </code></pre></div></div> <p>Then you can, for example, do the following:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">a</span> <span class="o">=</span> <span class="no">BatchOpener</span><span class="p">.</span><span class="nf">open</span> <span class="s2">"/home/mark/confocal/test.lsm"</span> <span class="p">[</span><span class="no">Lij</span><span class="o">.</span><span class="no">ImagePlus</span><span class="p">;</span><span class="vi">@b1406b</span> <span class="o">>>></span> <span class="n">a</span><span class="p">.</span><span class="nf">length</span> <span class="mi">2</span> <span class="o">>>></span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">getTitle</span> <span class="no">C1</span><span class="o">-</span><span class="nb">test</span><span class="p">.</span><span class="nf">lsm</span> <span class="o">>>></span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">getTitle</span> <span class="no">C2</span><span class="o">-</span><span class="nb">test</span><span class="p">.</span><span class="nf">lsm</span> <span class="o">>>></span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nf">show</span> </code></pre></div></div> <h2 id="example-generating-a-plasma-cloud">Example: Generating a Plasma Cloud</h2> <p>In this first example, we’ll just create a small script to create a fractal “plasma cloud” image. We’ll start of experimenting in the interpreter to make sure we’ve got the code to create images correctly. To create the RGB image in the first place, we create a <code class="language-plaintext highlighter-rouge">ColorProcessor</code> and then an <code class="language-plaintext highlighter-rouge">ImagePlus</code> from that:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">w</span> <span class="o">=</span> <span class="mi">800</span> <span class="mi">800</span> <span class="o">>>></span> <span class="n">h</span> <span class="o">=</span> <span class="mi">600</span> <span class="mi">600</span> <span class="o">>>></span> <span class="n">cp</span> <span class="o">=</span> <span class="n">ij</span><span class="p">.</span><span class="nf">process</span><span class="o">.</span><span class="no">ColorProcessor</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">w</span><span class="p">,</span><span class="n">h</span><span class="p">)</span> <span class="n">ip</span><span class="p">[</span><span class="n">width</span><span class="o">=</span><span class="mi">800</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span> <span class="n">min</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">max</span><span class="o">=</span><span class="mf">255.0</span><span class="p">]</span> <span class="o">>>></span> <span class="n">i</span> <span class="o">=</span> <span class="n">ij</span><span class="o">.</span><span class="no">ImagePlus</span><span class="p">.</span><span class="nf">new</span> <span class="s2">"Plasma Cloud"</span><span class="p">,</span> <span class="n">cp</span> <span class="n">imp</span><span class="p">[</span><span class="no">Plasma</span> <span class="no">Cloud</span> <span class="mi">800</span><span class="n">x600x1</span><span class="p">]</span> </code></pre></div></div> <p>… and now show it:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">i</span><span class="p">.</span><span class="nf">show</span> </code></pre></div></div> <p>We’ll manipulate the pixel array directly, so it’s worth checking that this will work OK. Here we try to set half of the image to green:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">>>></span> <span class="n">i</span> <span class="n">imp</span><span class="p">[</span><span class="no">Plasma</span> <span class="no">Cloud</span> <span class="mi">800</span><span class="n">x600x1</span><span class="p">]</span> <span class="o">>>></span> <span class="n">pixels</span> <span class="o">=</span> <span class="n">cp</span><span class="p">.</span><span class="nf">getPixels</span> <span class="p">[</span><span class="no">I</span><span class="vi">@e038c4</span> <span class="o">>>></span> <span class="mi">0</span><span class="p">.</span><span class="nf">upto</span><span class="p">(</span> <span class="n">w</span> <span class="o">*</span> <span class="p">(</span><span class="n">h</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">j</span><span class="o">|</span> <span class="n">pixels</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="mh">0x0000FF00</span> <span class="p">}</span> <span class="mi">0</span> <span class="o">>>></span> <span class="n">i</span><span class="p">.</span><span class="nf">updateAndDraw</span> </code></pre></div></div> <p>Hopefully that worked OK. The color value specified there is in ARGB format. You may have noticed that this step was rather slow - there is quite a bit of magic involved in JRuby’s transparent access between Ruby and Java, which has an inevitable performance cost. But if your goal is not so much the speed with which the script is executed, but to get a working script as fast as possible, JRuby scripting may well be your optimal tool.</p> <p>(By the way, sometimes it’s even possible to use java’s optimizations in ruby. Replace the</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="mi">0</span><span class="p">.</span><span class="nf">upto</span><span class="p">(</span> <span class="n">w</span> <span class="o">*</span> <span class="p">(</span><span class="n">h</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">j</span><span class="o">|</span> <span class="n">pixels</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="mh">0x0000FF00</span> <span class="p">}</span> </code></pre></div></div> <p>with</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">java</span><span class="p">.</span><span class="nf">util</span><span class="o">.</span><span class="no">Arrays</span><span class="p">.</span><span class="nf">fill</span><span class="p">(</span><span class="n">pixels</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">w</span><span class="o">*</span><span class="n">h</span><span class="o">/</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mh">0x0000FF00</span><span class="p">)</span> </code></pre></div></div> <p>and get a free 240 times speedup.)</p> <p>You would probably proceed at this stage by switching to a text editor and creating a script with the extension “.rb” and underscores in the name in the Fiji plugins directory. You should find an example <code class="language-plaintext highlighter-rouge">Plasma_Cloud.rb</code> script in <code class="language-plaintext highlighter-rouge">plugins/Examples</code> which is based on the basics we worked out above. The output of this script looks like this:</p> <p><img src="/media/tutorials/plasma-cloud.png" alt="Example "Plasma Cloud" image" /></p> <h2 id="example-batch-converting-file-formats">Example: Batch Converting File Formats</h2> <p>This is a short example script showing how to convert a directory of LSM files into BioRad .PIC format using JRuby and the <code class="language-plaintext highlighter-rouge">util.BatchOpener</code> methods that I mentioned above. This just hard-codes the paths in the filesystem, so you would need to edit it if you want to do something similar. Nonetheless, hopefully this is instructive: filtering filenames, and so on, is typically much more convenient using JRuby than the ImageJ macro language:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">input_directory</span> <span class="o">=</span> <span class="s2">"/home/mark/lsm-examples/"</span> <span class="n">output_directory</span> <span class="o">=</span> <span class="s2">"/home/mark/lsm-examples/biorad/"</span> <span class="n">include_class</span> <span class="s1">'util.BatchOpener'</span> <span class="n">include_class</span> <span class="s1">'Biorad_Writer'</span> <span class="c1"># Check that the input directory exists:</span> <span class="k">unless</span> <span class="no">FileTest</span><span class="p">.</span><span class="nf">directory?</span> <span class="n">input_directory</span> <span class="n">ij</span><span class="o">.</span><span class="no">IJ</span><span class="p">.</span><span class="nf">error</span> <span class="s2">"Input directory '</span><span class="si">#{</span><span class="n">input_directory</span><span class="si">}</span><span class="s2"> was not found"</span> <span class="nb">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="k">end</span> <span class="c1"># Create the output directory if it doesn't exist:</span> <span class="k">unless</span> <span class="no">FileTest</span><span class="p">.</span><span class="nf">exist?</span> <span class="n">output_directory</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">mkdir</span> <span class="n">output_directory</span> <span class="k">end</span> <span class="c1"># Biorad filenames have a standard format, which we generate with</span> <span class="c1"># this function. ('channel' should be 1-indexed):</span> <span class="k">def</span> <span class="nf">make_biorad_filename</span><span class="p">(</span><span class="n">lsm_filename</span><span class="p">,</span><span class="n">channel</span><span class="p">)</span> <span class="n">lsm_filename</span><span class="p">.</span><span class="nf">gsub</span><span class="p">(</span><span class="sr">/.lsm$/</span><span class="p">,</span><span class="nb">sprintf</span><span class="p">(</span><span class="s2">"%02d.pic"</span><span class="p">,</span><span class="n">channel</span><span class="p">))</span> <span class="k">end</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">entries</span><span class="p">(</span><span class="n">input_directory</span><span class="p">).</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">e</span><span class="o">|</span> <span class="c1"># Skip anything that doesn't have a '.lsm' extension:</span> <span class="k">next</span> <span class="k">unless</span> <span class="n">e</span> <span class="o">=~</span> <span class="sr">/\.lsm$/</span> <span class="nb">puts</span> <span class="s2">"Converting: </span><span class="si">#{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># Open the image file to an array of ImagePlus objects:</span> <span class="n">a</span> <span class="o">=</span> <span class="no">BatchOpener</span><span class="p">.</span><span class="nf">open</span><span class="p">(</span><span class="s2">"</span><span class="si">#{</span><span class="n">input_directory</span><span class="si">}#{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="c1"># Create the writer plugin object:</span> <span class="n">writer</span> <span class="o">=</span> <span class="no">Biorad_Writer</span><span class="p">.</span><span class="nf">new</span> <span class="c1"># Now, for each channel in the input image, write out</span> <span class="n">index</span> <span class="o">=</span> <span class="mi">0</span> <span class="n">a</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">image</span><span class="o">|</span> <span class="c1"># The Biorad_Writer doesn't like COLOR_256 images, so convert to</span> <span class="c1"># GRAY8:</span> <span class="n">ij</span><span class="p">.</span><span class="nf">process</span><span class="o">.</span><span class="no">StackConverter</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">image</span><span class="p">).</span><span class="nf">convertToGray8</span> <span class="n">biorad_filename</span> <span class="o">=</span> <span class="n">make_biorad_filename</span> <span class="n">e</span><span class="p">,</span> <span class="n">index</span> <span class="o">+</span> <span class="mi">1</span> <span class="nb">puts</span> <span class="s2">" Writing: </span><span class="si">#{</span><span class="n">biorad_filename</span><span class="si">}</span><span class="s2">"</span> <span class="n">writer</span><span class="p">.</span><span class="nf">save</span> <span class="n">image</span><span class="p">,</span> <span class="n">output_directory</span><span class="p">,</span> <span class="n">biorad_filename</span> <span class="n">index</span> <span class="o">+=</span> <span class="mi">1</span> <span class="n">image</span><span class="p">.</span><span class="nf">close</span> <span class="k">end</span> <span class="k">end</span> <span class="n">ij</span><span class="o">.</span><span class="no">IJ</span><span class="p">.</span><span class="nf">showMessage</span><span class="p">(</span><span class="s2">"Finished converting to Biorad format!"</span><span class="p">)</span> </code></pre></div></div> <h3 id="converting-imagej-macros-to-jruby">Converting ImageJ Macros to JRuby</h3> <p>To help with porting existing ImageJ macros to JRuby, I have made a start on implementing similarly named JRuby functions to the standard ImageJ macros. These have been defined with idiomatic Ruby function names as well as the “lower camel case” style ImageJ macro names, so instead of <code class="language-plaintext highlighter-rouge">image = ij.IJ.getImage</code> as used above, you can use either:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">image</span> <span class="o">=</span> <span class="n">getImage</span> </code></pre></div></div> <p>or:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">image</span> <span class="o">=</span> <span class="n">get_image</span> </code></pre></div></div> <p>The <code class="language-plaintext highlighter-rouge">run</code> method may also be particularly useful for calling existing ImageJ plugins and commands. The next section has an example of the use of this. It may be instructive to compare the <a href="https://imagej.net/ij/macros/ConvexHull.txt">“Blobs Demo” macro</a> from the ImageJ distribution with <a href="https://github.com/fiji/fiji/blob/master/plugins/Examples/Blobs_Demo_in_Ruby.rb">a version ported to JRuby</a>. The use of the analogous function in JRuby is not always the same—for example, if you compare the invocation of <code class="language-plaintext highlighter-rouge">getSelectionCoordinates,</code> you’ll find that whereas the ImageJ macro version passes in the output variables:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">getSelectionCoordinates</span><span class="p">(</span><span class="n">xCoordinates</span><span class="p">,</span> <span class="n">yCoordinates</span><span class="p">);</span> </code></pre></div></div> <p>… the JRuby version can return two arrays:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">x_coordinates</span><span class="p">,</span> <span class="n">y_coordinates</span> <span class="o">=</span> <span class="n">get_selection_coordinates</span> </code></pre></div></div> <div class="notice" style="font-size: 2; background: #e6e6e6; border-left: 10px solid #bdbdbd"><div class="notice-icon"><img src="/media/icons/tech.png" /></div><div class="notice-content"> <p>A note for the interested programmer: About 15% of the macro functions have be done so far, and if anyone wanted to help out with doing the rest, that would be excellent! The source code <a href="https://github.com/fiji/fiji/blob/master/plugins/JRuby/imagej.rb">can be found here</a>.</p> </div> </div> <h2 id="example-generating-redcyan-anaglyphs">Example: Generating Red/Cyan Anaglyphs</h2> <p>This example script can be found in the <code class="language-plaintext highlighter-rouge">plugins/Examples/</code> folder of Fiji. It will take an image stack and generate from it an image that should appear in 3D when viewed through red and cyan glasses. All that this does is to do two maximum intensity projections from two slightly different angles and merges them together. It’s a nice example because all the work is done by existing ImageJ commands. If you look at the script, you’ll see that the first step is to run the “3D Project…” plugin with some slightly convoluted options:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">projection_options</span> <span class="o">=</span> <span class="s2">"projection=[Brightest Point] axis=Y-Axis "</span> <span class="n">projection_options</span> <span class="o">+=</span> <span class="s2">"initial=-</span><span class="si">#{</span><span class="n">degree_separation</span> <span class="o">/</span> <span class="mi">2</span><span class="si">}</span><span class="s2"> "</span> <span class="n">projection_options</span> <span class="o">+=</span> <span class="s2">"total=</span><span class="si">#{</span><span class="n">degree_separation</span><span class="si">}</span><span class="s2"> "</span> <span class="n">projection_options</span> <span class="o">+=</span> <span class="s2">"rotation=</span><span class="si">#{</span><span class="n">degree_separation</span><span class="si">}</span><span class="s2"> "</span> <span class="n">projection_options</span> <span class="o">+=</span> <span class="s2">"interpolate"</span> <span class="n">run</span> <span class="s2">"3D Project..."</span><span class="p">,</span> <span class="n">projection_options</span> </code></pre></div></div> <p>In general, the best way to figure out what these options should be is to start the macro recorder with <span class="bc"><span>Plugins</span> › <span>Macros</span> › <span>Record…</span></span> and run the plugin. In this case, the output in the macro recorder looks like this:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">run</span><span class="p">(</span><span class="s2">"3D Project..."</span><span class="p">,</span> <span class="s2">"projection=[Brightest Point] axis=Y-Axis slice=1.20 initial=-2 total=4 rotation=4 lower=1 upper=255 opacity=0 surface=100 interior=50 interpolate"</span><span class="p">);</span> </code></pre></div></div> <p>Hopefully it should be obvious how I derived the <code class="language-plaintext highlighter-rouge">projection_options</code> string in the script from that output. The next part of the script splits the hyperstack generated by that command and merges it with appropriate colours. Similarly this can be figured out with the help of the macro recorder, the only tricky bit being that one has to predict the names of the images that are output from each step. There are further helpful comments in the script itself.</p> <p>Some example output:</p> <p><img src="/media/anaglyph.png" alt="Example anaglyph image" /></p> <h2 id="script-parameters">Script Parameters</h2> <div class="notice" style="font-size: 2; background: #e6e6e6; border-left: 10px solid #fadd8d"><div class="notice-icon"><img src="/media/icons/imagej2.png" /></div><div class="notice-content"><p>This section describes features specific to <a href="/software/imagej2">ImageJ2</a>, which are not available in the original <a href="/software/imagej">ImageJ</a>.</p> </div> </div> <p>When using <a href="/scripting/parameters">Script Parameters</a>, e.g., in the <a href="/scripting/script-editor">Script Editor</a>, you need to use a <code class="language-plaintext highlighter-rouge">$</code> before <code class="language-plaintext highlighter-rouge">@ variables</code>, due to a limitation in the scoping, as in this example from <a href="/scripting/templates">Script Templates</a>:</p> <p><b><a href="https://github.com/scijava/scripting-jruby/blob/master/src/main/resources/script_templates/Intro/Greeting.rb">Greeting.rb</a></b><br /> <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fscijava%2Fscripting-jruby%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fscript_templates%2FIntro%2FGreeting.rb%23L1-99999&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script></p> <h2 id="library">Library</h2> <p>The <a href="/software/fiji">Fiji</a> distribution of ImageJ includes a library called <a href="https://github.com/fiji/fiji/blob/master/plugins/JRuby/imagej.rb">imagej.rb</a> for convenience. It contains a number of useful functions related to ImageJ. It is loaded by default when creating a new JRuby script in the <a href="/scripting/script-editor">Script Editor</a>.</p> <h2 id="what-next">What next?</h2> <p>You may want to first have a quick look at the <a href="/scripting">Scripting Help</a> page for generic instructions in using the interpreter and script interfaces, and the <a href="/scripting/comparisons">Scripting comparisons</a> page for an example written in several of the different scripting languages available. The JRuby example shows how to implement a Java interface in JRuby.</p> <p>JRuby offers some more nice features, have a look at them in the <a href="https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby">JRuby documentation</a>.</p> <p>And of course, if you want to know how to use a class from ImageJ or any of its projects, visit <a href="https://javadoc.scijava.org">javadoc.scijava.org</a>.</p> </div> </div> </section> <!-- Footer --> <section id="footer"> <ul class="icons"> <li><a href="https://forum.image.sc/tag/imagej" class="icon alt"><img src="/media/icons/image-sc.png" width="24" style="vertical-align: middle; margin-top: -10px"><span class="label">Forum</span></a></li> <li><a href="https://twitter.com/hashtag/ImageJ" class="icon brands alt fa-twitter"><span class="label">Twitter</span></a></li> <li><a href="https://github.com/imagej" class="icon brands alt fa-github"><span class="label">GitHub</span></a></li> </ul> <ul class="copyright"> <li>Design: <a href="http://html5up.net">HTML5 UP</a></li> </ul> </section> <!-- Hamburger menu --> <nav role="navigation"> <div id="ham-toggle"> <input type="checkbox" /> <span></span> <!-- top bun --> <span></span> <!-- hamburger --> <span></span> <!-- bottom bun --> <ul id="ham-menu"> <div class="menu"><h3>ImageJ Docs</h3> <ul> <li><a href="/downloads">Download</a></li> <li><details><summary>Learn</summary><ul> <li><details><summary><a href="/learn">ImageJ Basics</a></summary><ul> <li><a href="/tutorials">Tutorials</a></li> <li><a href="/learn/user-guides">User Guides</a></li> <li><a href="/learn/keyboard-shortcuts">Keyboard Shortcuts</a></li> <li><a href="/learn/tips-and-tricks">Tips and Tricks</a></li> <li><a href="/learn/troubleshooting">Troubleshooting</a></li> <li><a href="/learn/faq">Frequently Asked Questions</a></li> <li><details><summary><a href="/platforms">Supported Platforms</a></summary><ul> <li><a href="/platforms/windows">Windows</a></li> <li><a href="/platforms/macos">MacOS</a></li> <li><a href="/platforms/linux">Linux</a></li> <li><a href="/platforms/pi">Raspberry Pi</a></li> <li><a href="/platforms/android">Android</a></li> </ul></details></li> <!-- Learn/ImageJ Basics/Supported Platforms --> <li><details><summary><a href="/formats">File Formats</a></summary><ul> <li><a href="/formats/bio-formats">Bio-Formats</a></li> <li><a href="/formats/video">Video formats</a></li> <li><a href="/formats/quicktime">QuickTime</a></li> <li><a href="/formats/tiff">TIFF</a></li> <li><a href="/formats/pdf">PDF</a></li> <li><a href="/formats/dicom">DICOM</a></li> <li><a href="/formats/lsm">Zeiss LSM</a></li> <li><a href="/formats/olympus">Olympus VSI</a></li> <li><a href="/formats/lurawave">Opera Flex</a></li> <li><a href="/formats/fib-sem">FIB-SEM</a></li> </ul></details></li> <!-- Learn/ImageJ Basics/File Formats --> </ul></details></li> <!-- Learn/ImageJ --> <li><details><summary><a href="/imaging">Scientific Imaging</a></summary><ul> <li><a href="/imaging/principles">Principles of Scientific Imaging</a></li> <li><a href="/imaging/annotating-images">Annotating Images</a></li> <li><a href="/imaging/colocalization-analysis">Colocalization</a></li> <li><a href="/imaging/color-image-processing">Color Image Processing</a></li> <li><a href="/imaging/deconvolution">Deconvolution</a></li> <li><a href="/imaging/image-intensity-processing">Image Intensity Processing</a></li> <li><a href="/imaging/particle-analysis">Particle Analysis</a></li> <li><a href="/imaging/registration">Registration</a></li> <li><a href="/imaging/segmentation">Segmentation</a></li> <li><a href="/imaging/stack-slice-manipulations">Stack-slice Manipulations</a></li> <li><a href="/imaging/t-functions">T-functions</a></li> <li><a href="/imaging/tracking">Tracking</a></li> <li><a href="/imaging/visualization">Visualization</a></li> <li><a href="/imaging/z-functions">Z-functions</a></li> </ul></details></li> <!-- Learn/Scientific Imaging --> </ul></details></li> <!-- Learn --> <li><details open><summary><a href="/plugins">Extend</a></summary><ul> <li><a href="/list-of-extensions">List of Extensions</a></li> <li><details><summary><a href="/update-sites">Update Sites</a></summary><ul> <li><a href="/list-of-update-sites">List of Update Sites</a></li> <li><a href="/update-sites/following">Following an Update Site</a></li> <li><a href="/update-sites/setup">Creating an Update Site</a></li> <li><a href="/update-sites/tos">Terms of Service</a></li> <li><a href="/update-sites/automatic-uploads">Automatic Upload</a></li> <li><a href="/update-sites/core-uploads">Uploading to Core Sites</a></li> <li><a href="/update-sites/faq">Update Sites FAQ</a></li> <li><a href="/update-sites/stats">Statistics</a></li> </ul></details></li> <!-- Extend/Update Sites --> <li><details open><summary><a href="/scripting">Scripting</a></summary><ul> <li><a href="/scripting/basics">Scripting Basics</a></li> <li><a href="/scripting/script-editor">Script Editor</a></li> <li><a href="/scripting/parameters">Parameters</a></li> <li><a href="/scripting/user-input">User Input</a></li> <li><a href="/scripting/auto-imports">Auto Import</a></li> <li><a href="/scripting/templates">Templates</a></li> <li><a href="/scripting/batch">Batch Processing</a></li> <li><a href="/scripting/headless">Running Headlessly</a></li> <li><a href="/scripting/comparisons">Scripting Comparisons</a></li> <li><a href="/scripting/toolbox">Toolbox</a></li> <li><details open><summary>Languages</summary><ul> <li><a href="/scripting/beanshell">BeanShell Scripting</a></li> <li><a href="/scripting/groovy">Groovy Scripting</a></li> <li><a href="/scripting/macro">ImageJ Macro</a></li> <li><a href="/scripting/javascript">JavaScript</a></li> <li><a href="/scripting/clojure">Lisp (Clojure)</a></li> <li><a href="/scripting/matlab">MATLAB</a></li> <li><a href="/scripting/jython">Python (Jython)</a></li> <li><a href="/scripting/python">Python (native)</a></li> <li><a href="/scripting/renjin">R (Renjin)</a></li> <li><a class="current-page">Ruby (JRuby)</a></li> <li><a href="/scripting/scala">Scala Scripting</a></li> </ul></details></li> <!-- Extend/Scripting/Languages --> </ul></details></li> <!-- Extend/Scripting --> <li><details><summary><a href="/develop">Development</a></summary><ul> <li><a href="/develop/philosophy">Philosophy</a></li> <li><a href="/develop/architecture">Architecture</a></li> <li><a href="/develop/source">Source code</a></li> <li><a href="/develop/project-management">Project management</a></li> <li><a href="/develop/coding-style">Coding style</a></li> <li><a href="/develop/javadoc">Using Javadoc</a></li> <li><a href="/develop/debugging">Debugging</a></li> <li><a href="/develop/wish-list">Wish list</a></li> <li><details><summary>Tools</summary><ul> <li><a href="/develop/github">GitHub</a></li> <li><a href="/develop/maven">Maven</a></li> <li><a href="/develop/ci">CI/CD</a></li> <li><a href="/develop/dotfiles">Dotfiles</a></li> <li><details><summary><a href="/develop/ides">IDEs</a></summary><ul> <li><a href="/develop/eclipse">Eclipse</a></li> <li><a href="/develop/netbeans">NetBeans</a></li> <li><a href="/develop/intellij">IntelliJ IDEA</a></li> <li><a href="/develop/command-line">Command Line</a></li> </ul></details></li> </ul></details></li> <!-- Extend/Development/Tools --> <li><details><summary>Guides</summary><ul> <li><a href="/develop/plugins">Writing plugins</a></li> <li><a href="/develop/improving-the-code">Contributing to a plugin</a></li> <li><a href="/develop/releasing">Development lifecycle</a></li> <li><a href="/develop/building-a-pom">Building a POM</a></li> <li><a href="/develop/debugging-exercises">Hands-on debugging</a></li> <li><a href="/develop/writing-ops">Adding new ops</a></li> <li><a href="/develop/formats">Adding new formats</a></li> <li><a href="/develop/native-libraries">Using native libraries</a></li> <li><a href="/develop/tips">Tips for developers</a></li> <li><a href="/develop/cpp-tips">Tips for C++ developers</a></li> <li><a href="/develop/ij1-plugins">ImageJ 1.x plugins</a></li> <li><a href="/develop/versioning">Versioning</a></li> <li><a href="/develop/logging">Logging</a></li> <li><a href="/develop/uber-jars">Uber-JARs</a></li> </ul></details></li> <!-- Extend/Development/Guides --> <li><details><summary><a href="/develop/git">Git</a></summary><ul> <li><a href="/develop/git/eclipse">Git in Eclipse (EGit)</a></li> <li><a href="/develop/git/mini-howto">Git mini howto</a></li> <li><a href="/develop/git/workshop">Git workshop</a></li> <li><a href="/develop/git/conflicts">Git conflicts</a></li> <li><a href="/develop/git/topic-branches">Git topic branches</a></li> <li><a href="/develop/git/notes">Git notes</a></li> <li><a href="/develop/git/reflogs">Git reflogs</a></li> <li><a href="/develop/git/submodules">Git submodules</a></li> <li><a href="/develop/git/pinpoint-regressions">How to pinpoint regressions</a></li> <li><a href="/develop/git/publish-a-repository">How to publish a git repository</a></li> <li><a href="/develop/git/extract-a-subproject">How to extract a subproject</a></li> </ul></details></li> <!-- Extend/Development/Git --> </ul></details></li> <!-- Extend/Development --> </ul></details></li> <!-- Extend --> <li><details><summary><a href="/contribute">Contribute</a></summary><ul> <li><a href="/contribute/citing">Citing</a></li> <li><a href="/people">Contributors</a></li> <li><a href="/orgs">Organizations</a></li> <li><a href="/contribute/governance">Governance</a></li> <li><a href="/contribute/funding">Funding</a></li> <li><a href="/contribute/fiji">Contributing to Fiji</a></li> <li><details><summary><a href="/licensing">Licensing</a></summary><ul> <li><details><summary><a href="/licensing/open-source">Open Source</a></summary><ul> <li><a href="/licensing/apache">Apache</a></li> <li><a href="/licensing/bsd">BSD</a></li> <li><a href="/licensing/epl">EPL</a></li> <li><a href="/licensing/gpl">GPL</a></li> <li><a href="/licensing/lgpl">LGPL</a></li> <li><a href="/licensing/mit">MIT</a></li> <li><a href="/licensing/public-domain">Public domain</a></li> <li><a href="/licensing/big">BIG</a></li> </ul></details></li> <!-- Contribute/Licensing/Open Source --> <li><a href="/licensing/closed-source">Proprietary</a></li> </ul></details></li> <!-- Contribute/Licensing --> <li><details><summary><a href="/editing">Editing the Wiki</a></summary><ul> <li><a href="/editing/advanced">Advanced Editing</a></li> <li><a href="/editing/buttons">Buttons</a></li> <li><a href="/editing/citations">Citations</a></li> <li><a href="/editing/code">Source Code</a></li> <li><a href="/editing/debugging">Debugging</a></li> <li><a href="/editing/headers">Headers</a></li> <li><a href="/editing/icons">Icons</a></li> <li><a href="/editing/images">Images</a></li> <li><a href="/editing/keys">Keyboard Shortcuts</a></li> <li><a href="/editing/linking">Linking</a></li> <li><a href="/editing/math">Math Expressions</a></li> <li><a href="/editing/menu-paths">Menu Paths</a></li> <li><a href="/editing/navigation">Navigation</a></li> <li><a href="/editing/notices">Notices</a></li> <li><a href="/editing/people">People</a></li> <li><a href="/editing/pitfalls">Pitfalls</a></li> <li><a href="/editing/quizzes">Quizzes</a></li> <li><a href="/editing/statbox">Statbox</a></li> <li><a href="/editing/symbols">Symbols</a></li> <li><a href="/editing/tables">Tables</a></li> <li><a href="/editing/tooltips">Tooltips</a></li> <li><a href="/editing/videos">Videos</a></li> <li><a href="/editing/whitespace">Whitespace</a></li> </ul></details></li> <!-- Contribute/Editing the Wiki --> </ul></details></li> <!-- Contribute --> <li><details><summary><a href="/discuss">Discuss</a></summary><ul> <li><a href="/discuss/bugs">Reporting Issues</a></li> <li><a href="/discuss/mailing-lists">Mailing Lists</a></li> <li><a href="/discuss/chat">Chat</a></li> </ul></details></li> <!-- Discuss --> <li><details><summary>Explore</summary><ul> <li><a href="/news">News</a></li> <li><details><summary><a href="/events">Events</a></summary><ul> <li><a href="/events/presentations">Presentations</a></li> <li><a href="/events/conferences">Conferences</a></li> <li><a href="/events/hackathons">Hackathons</a></li> <li><a href="/events">More...</a></li> </ul></details></li> <!-- Discuss/Events --> <li><details><summary><a href="/libs">Libraries</a></summary><ul> <li><a href="/libs/imagej-ops">ImageJ Ops</a></li> <li><a href="/libs/imagej-common">ImageJ Common</a></li> <li><a href="/libs/imagej-legacy">ImageJ Legacy</a></li> <li><a href="/libs/scijava">SciJava</a></li> <li><a href="/libs/scifio">SCIFIO</a></li> <li><details><summary><a href="/libs/imglib2">ImgLib2</a></summary><ul> <li><a href="/libs/imglib2/getting-started">Getting Started</a></li> <li><a href="/libs/imglib2/accessors">Accessors</a></li> <li><a href="/libs/imglib2/accessibles">Accessibles</a></li> <li><a href="/libs/imglib2/examples">Examples</a></li> <li><a href="/libs/imglib2/workshop-introductory">Introductory Workshop</a></li> <li><a href="/libs/imglib2/workshop-advanced">Advanced Workshop</a></li> <li><a href="/libs/imglib2/matlab">ImgLib2 images in MATLAB</a></li> <li><a href="/libs/imglib2/benchmarks">Benchmarks</a></li> <li><a href="/libs/imglib2/faq">FAQ</a></li> <li><a href="/libs/imglib2/developing">Developing ImgLib2</a></li> <li><a href="/libs/imglib2/discussion">ImgLib2 Discussion</a></li> </ul></details></li> <!-- Explore/Libraries/ImgLib2 --> <li><a href="/libs">More...</a></li> </ul></details></li> <!-- Explore/Libraries --> <li><details><summary><a href="/software">Software</a></summary><ul> <li><a href="/software/nih-image">NIH Image</a></li> <li><a href="/software/imagej">ImageJ</a></li> <li><a href="/software/imagej2">ImageJ2</a></li> <li><a href="/software/fiji">Fiji</a></li> <li><a href="/software">More...</a></li> </ul></details></li> <!-- Explore/Software --> </ul></details></li> <!-- Explore --> </ul> </div> </ul> </div> </nav> <div id="dock-overlay-left" class="dock-overlay" data-dock-target="left-column"></div> <div id="dock-overlay-right" class="dock-overlay" data-dock-target="right-column"></div> <!-- Search results --> <div id="search-results"> <div id="search-hits"></div> <div id="pagination"></div> </div> <!-- Scripts --> <!-- Libraries --> <script src="/assets/js/jquery.min.js"></script> <script src="/assets/js/jquery.scrolly.min.js"></script> <script src="/assets/js/browser.min.js"></script> <script src="/assets/js/breakpoints.min.js"></script> <script src="/assets/js/util.js"></script> <script src="/assets/js/jquery.toc.js"></script> <script src="/assets/js/lightbox.min.js"></script> <!-- Extensions --> <!-- Site code --> <script src="/assets/js/main.js"></script> <script src="/assets/js/dock.js"></script> <script src="/assets/js/code.js"></script> <!-- Anchors --> <script src="https://cdn.jsdelivr.net/npm/anchor-js/anchor.min.js"></script> <script>anchors.add('#page h1, #page h2, #page h3, #page h4, #page h5, #page h6');</script> <!-- Citations --> <script src="https://cdn.jsdelivr.net/npm/citation-js@0.4.0-9"></script> <script src="/assets/js/cite.js"></script> <!-- Search --> <script src="https://cdn.jsdelivr.net/npm/algoliasearch@4.13.0/dist/algoliasearch-lite.umd.js"></script> <script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4.40.3/dist/instantsearch.production.min.js"></script> <script src="/assets/js/search.js"></script> <script src="/assets/js/search-tweaks.js"></script> </body> </html>