Recover modal gray value Jython

jython
imagej
scripting

#1

Anyone knows which field in the API documentation of ImageStatistics corresponds to the modal gray level ?
The mode and MODE attributes do not return the same value than what I have in the measurement table…
or is it a relative value ?

#@ImagePlus imp

IP = imp.getProcessor()
FullStat = IP.getStatistics()

# modal gray fromResult table -> 11165 with a 16-bit image
print FullStat.mode # -> 156
print FullStat.MODE # -> 8

#2

Use ‘dmode’. Here is a JavaScript example:

  img = IJ.openImage("http://wsr.imagej.net/images/m51.zip");
  img.show();
  IJ.run("Set Measurements...", "area mean modal");
  IJ.run(img, "Measure", "");
  ip = img.getProcessor();
  stats = ip.getStatistics();
  IJ.log("mode="+stats.dmode);