Add stats.mode op to compute modal value
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 94
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
To my knowledge, there's currently no op available to compute modal values.
The ImageJ 1.x implementation is e.g. [here in `ShortProcessor`](https://github.com/imagej/imagej1/blob/08d498fad5c3ac41b6fd04a6de4bf9a90b2ba8b8/ij/process/ShortStatistics.java#L103-L106)
As a workaround, the `mode` can be computed as in [this gist](https://gist.github.com/imagejan/8bdb771ba653571cc07438c8e24dba79):
```
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](https://forum.image.sc/t/compute-modal-gray-value-in-knime-imagej2/36353?u=imagejan) [two](https://forum.image.sc/t/histogram-from-result-table/11628/7?u=imagejan) forum topics.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked ImageJ 1.x implementation in ShortStatistics.java and the existing histogram and Max.findMax operations referenced in the workaround. Add a stats.mode operation that returns the modal value, then verify it against histogram-based examples and the linked ImageJ behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- computer-vision
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100