User Tools

Site Tools


testing Groovy - ImageJ

There is a new ImageJ plugin that allows you to fo scripting with Groovy.


so I became interested in how it would be like using it. GroovyConsole seems to be an handy Editor, so instead of installing the plugin to ImageJ, I made a trial to use ImageJ as a libray, accessing directly from Groovy. It was pretty simple to do this task, but I note down how I installed mainly because I will forget what I did.

1. Go to the groovy site, and download the zipped binary.

I downloaded Groovy 1.7.8 and unzipped the folder groovy-1.7.8 under C:\dev.

2. Add path C:\dev\groovy-1.7.8 as a new environmental variable “GROOVY_HOME” .

3. Add path %GROOVY_HOME%\bin to the system path.

4. Launch the console by clicking %GROOVY_HOME%\bin\GroovyConsole.bat

5. set path to ij.jar by [Script > Add Jar to Classpath]

Following is the code I tested, which worked fine without opening ImageJ main menu.

import ij.*

imp = IJ.openImage("");

Running this code, an image window pops sup and also the width of the image is printed in the output field of the console. IJ.log command which normally should print out the string argument in log window seems to be diverted to the console output.
Interpreter runs with a speed comparable to Javascript and Jython running with ImageJ jar.

Good point about this console is that referencing to a jar file could be easily be done, by [scripts > add jar to classpath] This affords a good simple interface for test assembling several Java libraries.

blogtng/2011-03-07/testing_groovy_-_imagej.txt · Last modified: 2016/05/24 12:46 by

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki