Skip to content

Instantly share code, notes, and snippets.

@lacan
Last active October 28, 2021 23:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lacan/2b6cfa1710f3076ef7a4 to your computer and use it in GitHub Desktop.
Save lacan/2b6cfa1710f3076ef7a4 to your computer and use it in GitHub Desktop.
Measures the regularity index from an ImageJ Voronoi diagram #ImageJ #Fiji #Macro
/**
* Regularity Index Measurement
* Author: Olivier Burri
* Contact: http://biop.epfl.ch/INFO_Facility.html#staff
* Affiliation: BioImaging & Optics Platform, EPFL School of Life Sciences
* Date: 18 August 2015
* License: CC BY http://creativecommons.org/licenses/by/4.0/
*
* Description: Measures the regularity index from an ImageJ Voronoi diagram
*
* NOTES: Make sure that "AREA" is selected under "SET MEASUREMENTS"
*/
// For Demo's Sake
run("Blobs (25K)");
setAutoThreshold("Default");
setOption("BlackBackground", false);
run("Convert to Mask");
run("Voronoi");
// This performs the Voronoi Regularity Index Analysis
name = getTitle();
setThreshold(0, 0);
setOption("Area", true);
run("Analyze Particles...", "display exclude clear add");
//Get the areas
nR = nResults;
areas = newArray(nR);
for (i=0; i<nR; i++) {
areas[i] = getResult("Area", i);
}
// Compute mean and STDEV
Array.getStatistics(areas, min, max, mean, stdDev);
// Finally we have the regularity index
regIndx = mean/stdDev;
// Output to Log
print(name+" Regularity Index = "+d2s(mean,1)+" / "+d2s(stdDev,1)+"= "+d2s(regIndx,1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment