Creation of a new plug-in in Eclipse (beginner's question)

imagej
#1

Dear all,

I want to try out java plug-ins from the book Digital Image Processing (Burger/Burge). However, I have no experience with Java and Eclipse and got stuck in setting up Eclipse properly.

What I did:
I integrated ImageJ to Eclipse following http://imagej.net/Developing_ImageJ_in_Eclipse and could start it.

Problem:
I want to test a class from the book (e.g. http://imagingbook.bitbucket.org/javadoc/imagingbook_plugins_en1/src-html/Ch03_ImageJ_Introduction/My_Inverter_A.html#line.20 ).
Where in the imagej-tree in Eclipse would I create this class?
What else do I have to consider?

Thank you for your help!

0 Likes

#2

Dear @aklemm,

you should take a closer look at http://imagej.net/Developing_ImageJ_in_Eclipse#Adding_new_plugins.

This will direct you to a GitHub repository that contains a minimal ImageJ(1) plugin. After you have imported this project into Eclipse,you can place the classes from the book in the same directory (i.e. src/main/java) as Process_Pixels.java.

You will have to consider, that the excerpt you have posted does not contain a main method. Therefore, you will not be able to run it directly from within Eclipse. For further information, revisit http://imagej.net/Developing_ImageJ_in_Eclipse.

Best,
Stefan

2 Likes

#3

Dear Stefan,

thank you very much for your help!
I imported the minimal ImageJ(1) plugin to Eclipse, copied the book-example, built the project, copied the Process_Pixels-0.1.0-SNAPSHOT.jar file to the .jar folder in Fiji, and installed it in Fiji. Here appears under Process>Process Pixels.
And that is where I struggle now:

  • running Process Pixels doesn’t open the clown anymore, but opens the interface (is that normal?)
  • Where would I find the book example?

If you could guide me to more information this would be great. Thank you.
Best,
Anna

0 Likes

#4

Good morning @aklemm,

the creation of menu items for custom plugins in ImageJ1 is controlled by a plugins.config file that you can find in src/main/resources. You have to create an entry (i.e. add a line) for your plugin:

Process, "Anna's Inverter", My_Inverter_A

This will add the book example to the menu in ImageJ. For more information you can take a look at http://imagej.net/Introduction_into_Developing_Plugins#What_are_plugins_.28in_terms_of_menu_entries.29.3F as well as the awesome tutorial on ImageJ plugin development by Werner Bailer.

running Process Pixels doesn’t open the clown anymore, but opens the interface (is that normal?)

This is entirely normal since you are executing your plugin with two different mechanisms:

  1. When starting a plugin from within Eclipse it treats the class you are executing (per default) as a standalone Java application. Hence, the main method of the class will be executed, which contains the code to load the clown sample image.

  2. When a plugin is started from the ImageJ menu, ImageJ will take care of executing the setup method and once you click the menu entry of calling the run method. This run method also contains the code to generate a dialog, which I guess is the “interface” you are referring to?

Best,
Stefan

2 Likes

#5

Dear Stefan,

yes, now it works - great!
Indeed, I meant the dialog window with interface.
Thanks so much for your explanations and the links, they were very useful for me.

Best,
Anna

0 Likes