imagej / imagej-ops

ImageJ Ops: "Write once, run anywhere" image processing
https://imagej.net/libs/imagej-ops
BSD 2-Clause "Simplified" License
88 stars 42 forks source link

Add stats.mode op to compute modal value #622

Open imagejan opened 4 years ago

imagejan commented 4 years ago

To my knowledge, there's currently no op available to compute modal values.

The ImageJ 1.x implementation is e.g. here in ShortProcessor

As a workaround, the mode can be computed as in this gist:

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)

See also these two forum topics.