Script to export weka segmentation as ROI

Sample image and/or macro code

import trainableSegmentation.*;
import ij.IJ;
import ij.ImagePlus;

// input train image
input  = IJ.openImage( someImage.jpg" );

// create Weka Segmentation object
segmentator = new WekaSegmentation( input );

// load classifier from file
segmentator.loadClassifier( "classifier.model" );

result = segmentator.applyClassifier( input );

Background

I am scripting using Weka plugin for classifying different regions of the image and I wanted to obtain those regions for further processing… (as Rois? a table with the classes?)…

Analysis goals

I want to get the percentage of area for each of the segmented classes

Challenges

I need to script this task as it is part of a pipeline… But not sure how to do extract the results from Weka…