[ImageJ-devel] K-means clustering plugin

Rasband, Wayne (NIH/NIMH) [E] rasbandw at mail.nih.gov
Thu Jan 2 13:26:13 CST 2014


On Jan 2, 2014, at 1:21 PM, Safaa Al-Haj Saleh wrote:

> Hi all,
> 
> I have installed "ij_clustering.jar" that contains KMeansClustering plugin. I am trying to call this plugin from java code as the following:
> 
> IJ.runPlugIn(imp,"KMeansClustering","");
> 
> or using 
> 
> IJ.run(imp,"k-means Clustering","number=2 cluster=0.00010000 enable randomization=176");
> to run the installed plugin from imageJ menus.
> 
> The problem is that the resulted image is not clustered at all (i.e. it remains the same). I think the third parameter (arg) should be set in the first command, but I have no idea how to set it.
> 
> My point is that how to run installed imageJ plugins in my java code?

You can get the code needed to run the plugin by running the Plugins>Segmentation>KMeansClustering command with the recorder (Plugins>Macros>Record) running. This is what I get when I run the KMeansClustering command (using default settings) with the recorder running in JavaScript mode:

imp = IJ.getImage();
IJ.run(imp, "k-means Clustering ...", "number_of_clusters=4 cluster_center_tolerance=0.00010000 enable_randomization_seed randomization_seed=48");

I get the same results by running this code as I do when running the menu command. Note that there should not be any line breaks in the second line of code.

-wayne




More information about the ImageJ-devel mailing list