Pages in this namespace:
Author: Vital (Vital.Gutierrez_Fernandez@onera.fr)
This tutorial consists in a set of instructions to use Eclipse to write plugins for ImageJ. Furthermore, a set simple plugins is provided to familiarize the reader to plugins functions going from the opening of images to modify the data in the results table. The author appreciates any email with requests of simple codes or suggestions. The readers are encouraged to become acquaintance with the book of Burger and Burge to learn about the Image Processing Science. As the author becomes more confident with the ImageJ Wiki, the format of the tutorials will be improved with images and videos.
In the How-Tos section http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:the_imagej_eclipse_howto, as well as in the tutorial of David Edenberg http://rsbweb.nih.gov/ij/docs/eclipse-tutorial/index.html it has been described several possible aproaches to use Eclipse and ImageJ together. Novel users, however, may find the extra capabilities in these installations not worth the extra complexity involved. The proposed solution consists in saving the plugins written with eclipse directly in the plugins folder of ImageJ. Furthermore, by adding the ImageJ jar file as a library to ImageJ, it is possible to have the coding facilities of Eclipse, while writting plugins for ImageJ. We shall start by the installation of eclipse and its configuration. This tutorial assumes you are using windows and that you already have installed ImageJ
Eclipse is a powerful text editor, which is well known for its application in Java coding. Nowadays, it can be use to write in C or fortran. Users should be aware that eclipse is extremely flexible and each person has a different design. The reader should not get discouraged by these extreme capacities. Instead, he/she is incouraged to use the inbuilt tutorials to get familiar with its properties. Although, this is not required for this tutorial. As we perform more complex tasks, the reader will become more familiar to this text editor. To start, we shall only use the Package explorer tag (where we see our plugins tree) and the central window (where we write our plugins). At this point we shall configure eclipse to use it in combination with ImageJ. This will be accomplished by saving our plugins directly in the ImageJ plugins folder and importing ImageJ into eclipse as a library.
At this point, we have configured Eclipse to work with ImageJ. Soon we shall create a plugin to check how this works. But first we shall add the ImageJ library to eclipse.
At the bottom of your Java Project, in the Package explorer tag you might see the ij.jar file and its location as a reference library (left click on the small arrow of Referennced libraries):
This source file contains the description of the ImageJ functions and algorithms. From now on as you move your mouse above an ImageJ class in eclipse it will provide you with a small description. As you will learn this is extremly usefull while writting plugins.
If the installation of Eclipse-ImageJ has been succesful, any new class in a package should be visible in the ImageJ plugins menu. Two things should be remember while creating a new plugin:
1) Creation of a New Pluging
To create a new package and a new class in Eclipse follow the following steps:
If you need to create a new class, but not a package, you just need to do steps 5 to 8. To see if the package and the plugin were rightly exported:
2) Importing a Plugin
In other cases, however, you may need to download a plugin from the ImageJ website and modify it. Moreover, The examples provided below can be modified and combined to produce more complex tasks. The first step in this coding process, consists in importing the java files into your Eclipse-ImageJ compilation.
You may observe on the right page on the package explorer that the i_create_duplicates_image.java has been included in the “downloads” package. However, you may also notice a small red square with a white cross in your class, package and java project. This illustrates how Eclipse shows you that there is an error in the code.
The reason for this error in the code is fairly common: you gave a name to your package that does not agree with the one of the class creator. To solve this problem follow these steps, using the quick fix solutions of eclipse:
Once ImageJ menus are updated or ImageJ reopened, you will see the new plugins in your Plugins menu in the “downloads” submenu.
3) Coping a plugin
Assuming you have two packages, you can simply copy a plugin by several ways including:
Unlike in the case of importing a class, Eclipse changes automatically the package declaration to the one of the current package.
The following codes consist in simple examples of ImageJ plugins. By their own, they have little use by any user. However, these functions are commonly used while writting any plugin. The aim of this work is to allow the reader to become familiar with the Java-ImageJ programing. For any doubt or problem please do not doubt to contanct (Vital.Gutierrez_Fernandez@onera.fr).