import ij.*; import ij.process.*; import ij.plugin.filter.*; /** This plugin counts the number of unique colors in an RGB image. It does not do anything else. This is merely Wayne Rasband's Color Counter https://imagej.nih.gov/ij/plugins/color-counter.html plugin with the output of color values stripped out so that it is 2-3 times faster Peter J. Lee 5/31/2016 */ public class Color_Count_Only implements PlugInFilter { ImagePlus imp; int colors; static final int MAX_COLORS = 16777216; int[] counts = new int[MAX_COLORS]; int slice; public int setup(String arg, ImagePlus imp) { this.imp = imp; return DOES_RGB+NO_UNDO+NO_CHANGES+DOES_STACKS; } public void run(ImageProcessor ip) { int[] pixels = (int[])ip.getPixels(); for (int i=0; i0) colors++; } IJ.log("Unique colors: "+colors); } } }