Skip to content

Instantly share code, notes, and snippets.

@lacan
Last active June 16, 2017 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lacan/6b40bba1f878f332b7dbb7468be2fbc8 to your computer and use it in GitHub Desktop.
Save lacan/6b40bba1f878f332b7dbb7468be2fbc8 to your computer and use it in GitHub Desktop.
Make a new table with only the bounding box and label informations #ImageJ #Fiji #Macro
/*
* Make a new table with only the bounding box and label informations
* Olivier BURRI, November 2016
* Provided as-is, based on a request on the ImageJ List
* http://forum.imagej.net/t/creating-and-saving-a-custom-table-from-results/3285?u=oburri
*/
nR = nResults;
label = newArray(nR);
x1 = newArray(nR);
y1 = newArray(nR);
x2 = newArray(nR);
y2 = newArray(nR);
// Grab the old results
for (i=0; i<nR;i++) {
label[i] = getResultLabel(i);
x1[i] = getResult("BX", i);
y1[i] = getResult("BY", i);
x2[i] = x1[i] + getResult("Width", i);
y2[i] = y1[i] + getResult("Height", i);
}
// Rename the old table
IJ.renameResults("Raw Results");
// Make the new table
for (i=0; i<nR;i++) {
setResult("Label", i, label[i]);
setResult("X1", i, x1[i]);
setResult("Y1", i, y1[i]);
setResult("X2", i, x2[i]);
setResult("Y2", i, y2[i]);
}
updateResults();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment