ijpb / MorphoLibJ

Collection of mathematical morphology methods and plugins for ImageJ
http://imagej.net/MorphoLibJ
GNU Lesser General Public License v3.0
101 stars 48 forks source link

Adds a convenience Static Class to append ResultsTables #18

Closed lacan closed 6 years ago

lacan commented 6 years ago

This helps combine results tables together.

Please let me know if this makes sense to you, or let me know what would be an easier way to combine results

Best

Oli

See the groovy code below as an example

import inra.ijpb.binary.*
import inra.ijpb.label.*
import inra.ijpb.measure.*
import ij.IJ
import ij.ImagePlus

def imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");

def img = imp.duplicate()
IJ.setAutoThreshold(img, "Triangle dark stack")
IJ.setAutoThreshold(img, "Default");
IJ.run(img, "Convert to Mask", "");
IJ.run(img, "Fill Holes", "stack")
IJ.run(img, "Watershed", "stack")

def labels = new ImagePlus("Labeled Image", BinaryImages.componentsLabeling( img.getProcessor(), 6, 32 ))

def im = new IntensityMeasures(imp, labels)

def res_mean = im.getMean()
double[] resol = new double[3]
resol[0] = 1;
resol[1] = 1;
resol[2] = 1;

new ResultsBuilder()
        .addResult(new LabeledVoxelsMeasure(imp, labels).getSumOfVoxels())
        .addResult(new IntensityMeasures(imp, labels).getMean())
        .getResultsTable()
        .show("Concatenated Results")
dlegland commented 6 years ago

Oh, Great! this is the kind of tool I was expecting from a long time! Your solution is simple and efficient, so it's OK for me for integrating it. And I can remove an item from my TODO list!

Best, David

lacan commented 6 years ago

Glad I was able to help!