Posted by
Ignacio Arganda-Carreras-2 on
URL: http://imagej.273.s1.nabble.com/Weka-3D-Trainable-Segmentation-in-Java-code-tp5019213p5019214.html
Hello Maurice,
I tried to replicate your error but I couldn't. Are you sure you're not
trying to load a classifier trained on 2D features instead of one trained
using 3D features? Your code worked for me.
And by the way, you don't need to set the training image anymore if you are
just loading a classifier and applying it to a new image. Have a look at
this example in the wiki
<
http://imagej.net/Scripting_the_Trainable_Weka_Segmentation#Example:_apply_classifier_to_all_images_in_folder>
.
Cheers!
On Wed, Aug 16, 2017 at 4:43 AM, Maurice Argive <
[hidden email]>
wrote:
> I'm using the following code to classify images from the command line:
>
> 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();
>
> and this has been working well for me for a few years. I noticed in a
> recent Fiji upgrade that there is now a 3D menu option. I'm trying to use
> that feature in code so I use:
>
> ImagePlus image = IJ.openImage("image-file-to-be-classified.tif");
> WekaSegmentation ws = new WekaSegmentation(true);
> ws.setTrainingImage(image);
> ws.loadClassifier("saved-model-file.model");
> ImagePlus output = ws.applyClassifier(image, 0, false);
> IJ.save(output, "output.tif");
> output.close();
> image.close();
>
> and it seems to be working until the applyClassifier method runs. I then
> get a number of HeadlessExceptions that I never got before. Is there a way
> to run the 3D segmentation in code without the GUI?
>
> Thanks!
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
Ignacio Arganda-Carreras, Ph.D.
Ikerbasque Research Fellow
Departamento de Ciencia de la Computacion e Inteligencia Artificial
Facultad de Informatica, Universidad del Pais Vasco
Paseo de Manuel Lardizabal, 1
20018 Donostia-San Sebastian
Guipuzcoa, Spain
Phone : +34 943 01 73 25
Website:
http://sites.google.com/site/iargandacarreras/--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html