Unable to implement filters in Java

dependencies
eclipse
java
Tags: #<Tag:0x00007fd542ee63c0> #<Tag:0x00007fd542ee6280> #<Tag:0x00007fd542ee6118>

#1

I am using the filter ‘Sigma Filter Plus’ in one of my tasks. When I installed the plugin into my FIJI an ran the ImageJ macro, the filter processes the image. However when I am trying to run the same on Java Eclipse, it doesn’t run the filter and displays the following error:

Unrecognized command: “Sigma Filter Plus”

I am facing the same issue with Kuwahara and Space Noise Reduce filters.

Unrecognized command: "Kuwahara Filter"
Unrecognized command: “Space Noise Reduce”

How do I resolve this issue?

Note: I have installed all the needed .java and .jar files w.r.t the above filters into my source projects.


#2

Hi,

Are you working on a ImageJ1 style plugin? In that case I think the problem is that when ImageJ is launched from the IDE, it’s looking for the plugins from the wrong folder.

Have a look at this example:

If you just need to run your plug-in to test it, create a main() method with

	public static void main(String[] args) {
		// start ImageJ
		new ImageJ();

		// open an image (if needed)
		ImagePlus image = IJ.openImage("path/to/a/test/image.jpg");
		image.show();

		// run your plugin
		IJ.runPlugIn(My_Plugin.getClass().getName(), "");
	}

If you also want the plug-ins to display in the menu when ImageJ is launched from the Eclipse, set the “plugins.dir” property (before calling new ImageJ())

		// set the plugins.dir property to make the plugin appear in the Plugins menu
		Class<?> clazz = My_Plugin.class;
		String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
		String pluginsDir = url.substring("file:".length(), url.length() - clazz.getName().length() - ".class".length());
		System.setProperty("plugins.dir", pluginsDir);

Best regards,
Richard


#3

Hi Richard,

Thanks for the quick reply. I implemented your code and output pops up the filter windows like it used to in ImageJ. Does this mean Eclipse is able to look for plugins in the correct folder or that’s ImageJ plugin being called?

Here’s a snippet of my code which isn’t running -

 IJ.runPlugIn(Gchannel, "Sigma Filter Plus","radius=3 use=1 minimum=0.1 outlier");
 //IJ.run(Gchannel, "Sigma Filter Plus","radius=3 use=1 minimum=0.1 outlier");

Thanks and Regards,
kbimagej