http://imagej.273.s1.nabble.com/Weka-3D-Trainable-Segmentation-in-Java-code-tp5019213p5019246.html
classifier. Then I used the following code to load that classifier and
> Hello Maurice,
>
> Can you tell me the exact steps you took and the code you are running? Did
> you use "Trainable Weka Segmentation 3D" to create the classifier?
>
> ignacio
>
> On Thu, Aug 17, 2017 at 3:04 AM, Maurice Argive <
[hidden email]>
> wrote:
>
> > Hi Ignacio,
> >
> > Thanks for the info. I created a new 3D model just to be sure and ran it
> in
> > the code. Now I'm getting this exception:
> >
> > Read class name: class 1
> >
> > Read class name: class 2
> >
> > Error while adjusting data!
> >
> > java.lang.NullPointerException
> >
> >
> > trainableSegmentation.WekaSegmentation.setEnabledFeatures(
> > WekaSegmentation.java:6420)
> >
> >
> > trainableSegmentation.WekaSegmentation.adjustSegmentationStateToData(
> > WekaSegmentation.java:4169)
> >
> >
> > trainableSegmentation.WekaSegmentation.loadClassifier(
> > WekaSegmentation.java:717)
> >
> > ClusterClassify.main(ClusterClassify.java:54)
> >
> >
> > at
> > trainableSegmentation.WekaSegmentation.setEnabledFeatures(
> > WekaSegmentation.java:6420)
> >
> > at
> > trainableSegmentation.WekaSegmentation.adjustSegmentationStateToData(
> > WekaSegmentation.java:4169)
> >
> > at
> > trainableSegmentation.WekaSegmentation.loadClassifier(
> > WekaSegmentation.java:717)
> >
> > at ClusterClassify.main(ClusterClassify.java:54)
> >
> > Apply Classifier
> >
> > Exception in thread "main" java.lang.NullPointerException
> >
> >
> > trainableSegmentation.WekaSegmentation.applyClassifier(
> > WekaSegmentation.java:4709)
> >
> > ClusterClassify.main(ClusterClassify.java:60)
> >
> >
> > at
> > trainableSegmentation.WekaSegmentation.applyClassifier(
> > WekaSegmentation.java:4709)
> >
> > at ClusterClassify.main(ClusterClassify.java:60)
> >
> > Any ideas on what could be causing this? Is there something else I need
> to
> > do? The sample data I'm running classifies correctly when using the Fiji
> > plugin.
> >
> > Thanks!
> >
> > Maurice
> >
> > On Wed, Aug 16, 2017 at 7:08 AM, Ignacio Arganda-Carreras <
> >
[hidden email]> wrote:
> >
> > > 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> > >
> >
> > --
> > 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>