Created
June 25, 2018 20:14
-
-
Save imagejan/8bdb771ba653571cc07438c8e24dba79 to your computer and use it in GitHub Desktop.
Get the mode of an image histogram in ImageJ (using ImageJ Ops and ImgLib2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ Img input | |
#@ OpService ops | |
import net.imglib2.algorithm.stats.Max | |
histogram = ops.run("histogram", input) | |
cursor = Max.findMax(histogram) | |
value = input.firstElement().copy() | |
histogram.getCenterValue(cursor.getLongPosition(0), value) | |
println "Mode value: $value" | |
println "Mode count: ${cursor.get()}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment