weka trainable segmentation in java code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

weka trainable segmentation in java code

Maurice Oscarson
Hello,

I've used the GUI-based Trainable Weka Segmentation plugin in ImageJ (Fiji)
to train a classifier. I've then saved the model and would like to apply
that classifier to other data sets in a non-GUI environment. There was a
posting on this list that showed how to run the classifier using a
beanshell script that I've followed to create Java code. This code works,
in that I can apply the classifier to other data sets in a non-GUI
environment and get output, but I don't get output that matches the output
I get if I load and apply the model within the GUI plugin. The code I'm
using is

ImagePlus image = IJ.openImage("image-file-to-be-classified.tif");

WekaSegmentation ws = new WekaSegmentation(image);

ws.loadClassifier("saved-model-file.model");

ImagePlus output = ws.applyClassifier(image, 0, false);

IJ.save(output, "output.tif");

output.close();
image.close();

It is my understanding that the model should contain the features, etc.
used on the training set. Are there other settings or configurations that I
need to account for in the Java code so the output matches the output from
the GUI?

Thanks!

Maurice

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: weka trainable segmentation in java code

Ignacio Arganda-Carreras
Hello Maurice,

I'm assuming you have the latest version of the plugin (obtained through
the Fiji updater).

The code you posted is right and it should give you exactly the same output
as if you load any image in the GUI, then load the classifier (by clicking
on the "load classifier" button) and finally apply the classifier selecting
your image-file-to-be-classified.tif. If this is not the case, then there
is a bug I need to fix and would really appreciate if you could send me the
original image, the trained model and the expected result image.

To answer your last question, the list of features to use by the classifier
are indeed part of the model, so they should be calculated properly.

Best,

ignacio


On Wed, Apr 16, 2014 at 7:04 PM, Maurice Oscarson <
[hidden email]> wrote:

> Hello,
>
> I've used the GUI-based Trainable Weka Segmentation plugin in ImageJ (Fiji)
> to train a classifier. I've then saved the model and would like to apply
> that classifier to other data sets in a non-GUI environment. There was a
> posting on this list that showed how to run the classifier using a
> beanshell script that I've followed to create Java code. This code works,
> in that I can apply the classifier to other data sets in a non-GUI
> environment and get output, but I don't get output that matches the output
> I get if I load and apply the model within the GUI plugin. The code I'm
> using is
>
> ImagePlus image = IJ.openImage("image-file-to-be-classified.tif");
>
> WekaSegmentation ws = new WekaSegmentation(image);
>
> ws.loadClassifier("saved-model-file.model");
>
> ImagePlus output = ws.applyClassifier(image, 0, false);
>
> IJ.save(output, "output.tif");
>
> output.close();
> image.close();
>
> It is my understanding that the model should contain the features, etc.
> used on the training set. Are there other settings or configurations that I
> need to account for in the Java code so the output matches the output from
> the GUI?
>
> Thanks!
>
> Maurice
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Ignacio Arganda-Carreras, Ph.D.
Seung's lab, 46-5065
Department of Brain and Cognitive Sciences
Massachusetts Institute of Technology
43 Vassar St.
Cambridge, MA 02139
USA

Phone: (001) 617-324-3747
Website: http://bioweb.cnb.csic.es/~iarganda/index_EN.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: weka trainable segmentation in java code

luckyluke
In reply to this post by Maurice Oscarson
Hi Marucie,

Can you mention from where or which version you are using to work on above codes.

Where is the link in Github to make above codes on Eclipse?

Thanks if anyone helps me
Reply | Threaded
Open this post in threaded view
|

Re: weka trainable segmentation in java code

luckyluke
In reply to this post by Maurice Oscarson
Hi Marucie,

Can you mention from where or which version you are using to work on above codes.

Where is the link in Github to make above codes on Eclipse?

Thanks if anyone helps me
Reply | Threaded
Open this post in threaded view
|

Re: weka trainable segmentation in java code

luckyluke
In reply to this post by Maurice Oscarson
Hi Marucie,

Can you mention from where or which version you are using to work on above codes.

Where is the link in Github to make above codes on Eclipse?

Thanks if anyone helps me