I’m trying to develop a macro (in ijm format ) equivalent to https://imagej.net/Scripting_the_Trainable_Weka_Segmentation#Example:_apply_classifier_to_all_images_in_folder
that does exactly what I intended, but is coded as a Beanshell script (I need to edit some parts of the code and I’m not fluent in Beanshell, that’s why I would want to go for ijm language).
I was able to do that, but the replacement for the next two code lines sounds odd to me
// create segmentator segmentator = new WekaSegmentation(); // load classifier segmentator.loadClassifier( modelPath.getCanonicalPath() );
I can’t just load the classifier without previously open the main weka window, and to do that I need an image previously loaded into memory. The way I found to overcome the problem was to create / open a dummy image.
newImage("Untitled", "8-bit black", 512, 512, 1); run("Advanced Weka Segmentation"); wait(3000); call("trainableSegmentation.Weka_Segmentation.loadClassifier", modelPath);
and then call
call("trainableSegmentation.Weka_Segmentation.applyClassifier", inDir, list[it], "showResults=true", "storeResults=true", "probabilityMaps=true", outDir);
This approach, in addition to forcing me to create an extra image, makes it unable to run everything in batch mode, since the main weka window (and therefore the first image) must be visible. Is there any other alternative using ijm language?