Posted by
Nikolay Kladt on
Jan 29, 2015; 9:22am
URL: http://imagej.273.s1.nabble.com/Trainable-Weka-segmentation-Probability-map-but-not-Classiefied-image-produced-by-macro-tp5011357p5011362.html
Hi Martin,
I think there is a bug in the Weka Segmentation function public static void
getResult(). If I compare this function to the public static void
getProbability(), the getProbability function sets wekaSegmentation.
applyClassifier(true) before actually getting the classified image. I did
not delve deeper into this issue and also did not add code changes to the
segmentation plugin for testing, but I used this to get the macro working
with following workaround.
This also seems to explain why following workaround in the macro works:
call("trainableSegmentation.Weka_Segmentation.getProbability"); -> to
ensure that a classified image was created. selectWindow("Trainable Weka
Segmentation v2.1.7");
call("trainableSegmentation.Weka_Segmentation.getResult");
If you now close the Probability map window in choice==2, this worked on my
machine although this makes the macro slightly longer to run as the
probability maps are calculated anyway.
Niko
On Wed, Jan 28, 2015 at 6:43 PM, Martin Höhne <
[hidden email]>
wrote:
> 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
>
>
>
> --
> View this message in context:
>
http://imagej.1557.x6.nabble.com/Trainable-Weka-segmentation-Probability-map-but-not-Classiefied-image-produced-by-macro-tp5011357.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
Dr. Nikolay Kladt
Image and Data Analyst, CECAD Imaging Facility
[hidden email]
++49 221 478 84028
https://www.linkedin.com/in/kladtnCECAD Cologne - Excellent in Aging Research
Universität zu Köln
Joseph-Stelzmann Str. 26
50931 Cologne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html