Login  Register

Trainable Weka segmentation: Probability map but not Classiefied image produced by macro

Posted by Martin Höhne on Jan 28, 2015; 5:43pm
URL: http://imagej.273.s1.nabble.com/Trainable-Weka-segmentation-Probability-map-but-not-Classiefied-image-produced-by-macro-tp5011357.html

Dear all,

I try to get a Classified image created by a macro but this does not work for me. Creating a probability map works fine though.
I modified the example macro from this page

http://fiji.sc/Trainable_Weka_Segmentation#Macro_language_compatibility

to reproduce what I mean (pasted below).

If I select [1-probability map] in the beginning, the macro does what  I expect. If I select [2- classified image] nothing happens. I can manually click on "Create result" and the Classified image is created. Shouldn´t that work from the macro as well?

Thanks for helping
Martin

I´m using
(Fiji Is Just) ImageJ 2.0.0-rc-23/1.49m


***************macro to reproduce the behaviour**************

//get home directory
home=getDirectory("home");

//choice between probability maps or classified image
Dialog.create("Info");
        Dialog.addNumber("Probability map [1] or Classified image [2] ? ",1);
        Dialog.show();
        choice=Dialog.getNumber();  

// Open Leaf sample
run("Leaf (36K)");
 
// start plugin
run("Trainable Weka Segmentation");
 
// wait for the plugin to load
wait(3000);
selectWindow("Trainable Weka Segmentation v2.1.7");
 
// add one region of interest to each class
makeRectangle(367, 0, 26, 94);
call("trainableSegmentation.Weka_Segmentation.addTrace", "0", "1");
makeRectangle(186, 132, 23, 166);
call("trainableSegmentation.Weka_Segmentation.addTrace", "1", "1");
 
// train current classifier
call("trainableSegmentation.Weka_Segmentation.trainClassifier");

// save current classifier
call("trainableSegmentation.Weka_Segmentation.saveClassifier", home+File.separator+"testclassifier.model");

// close weka plugin
selectWindow("Trainable Weka Segmentation v2.1.7");
run("Close");
wait(3000);

// start plugin again
run("Trainable Weka Segmentation");
 
// wait for the plugin to load
wait(3000);
selectWindow("Trainable Weka Segmentation v2.1.7");

//load classifier
call("trainableSegmentation.Weka_Segmentation.loadClassifier", home+File.separator+"testclassifier.model");

// display probability maps or Classified image

if (choice==1) call("trainableSegmentation.Weka_Segmentation.getProbability"); //this works fine
if (choice==2) call("trainableSegmentation.Weka_Segmentation.getResult"); //this does not work