Skip to content

Instantly share code, notes, and snippets.

@imagejan
Created June 25, 2018 20:14
Show Gist options
  • Select an option

  • Save imagejan/8bdb771ba653571cc07438c8e24dba79 to your computer and use it in GitHub Desktop.

Select an option

Save imagejan/8bdb771ba653571cc07438c8e24dba79 to your computer and use it in GitHub Desktop.

Revisions

  1. imagejan created this gist Jun 25, 2018.
    12 changes: 12 additions & 0 deletions Mode_of_Image_Histogram.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #@ 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()}"