Login  Register

how can I call/execute/run a trained weka classifier from an ImageJ macro?

Posted by Dionysios Lefkaditis on Feb 05, 2013; 11:01am
URL: http://imagej.273.s1.nabble.com/how-can-I-call-execute-run-a-trained-weka-classifier-from-an-ImageJ-macro-tp5001668.html

Hi everybody!

What I am trying to do is to classify an image using a trained WEKA model. I am well aware of the existence of the Advanced Weka Segmentation plugin of ImageJ/Fiji, but I am using a custom-made feature vector, which will not work with it.

Anyway, within an ImageJ macro I am trying to execute:

exec("java", "-cp", "/home/dionysis/weka-3-7-7/weka.jar", "weka.classifiers.trees.RandomForest",  "-T", "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-data-20121218.arff", "-l", "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-ranfor-classifier-20121218.model.model", "-p", "0", ">", "/home/dionysis/Desktop/testrun-data.out");

which in essence is running the terminal command for weka. In the linux terminal this is running fine, however, calling it within the macro it doesn't do anything. It does not even produce an error.

In the beginning, I thought the problem was that I was trying to run a java program on the system's JVM called from a java program running on a different JVM (ImageJ/Fiji are bundled with their own JVM). For this reason, I tried running ImageJ/Fiji using the system's JVM, but no luck.

I am also considering using the embedded weka of the Advanced Weka Segmentation plugin through the call() macro function, but I do not know how to proceed.

Does anybody have any hints on this? I would greatly appreciate it... Thanks!

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html