KMeans Points Clustering
Labeling non-connected components as a sinlge object using K-means clustering.
Segmented objects sometimes are undesirably discontinuous due to weak signal. If number of objects are already known, then we can use k-means clustering algorithm to label isolated dots as a single object, and this script is an implementation of such algorithm. It was written for 3D data set, but also works with 2D data.
The latest ImageJ + Apatch Commons Math.
Fiji already includes Apache Commons Math, so no need of installing additional library.
Simply running the code from either menu tree or with a direct run using Script Editor triggers a GUI to input two parameters, expected number of clusters and the number of iteration for computation.
The script can be executed from ImageJ macro.
kmeansfunc = "/<path>/<to>/KMeans_Points_Clustering.py"; runMacro(kmeansfunc, "4 100");
<path>/<to> should be replaced with the path to the jython code in your local file system. The second argument of runMacro is the option values. The first one (“4” in the above) is the number of expected cluster. The second number is number of iterations (“10” in the above).
If the script is copied under
run("KMeans Points Clustering", "4 10");