imagej / imagej/imagej-ops

Yen threshold differs from IJ1

Open
#636 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
94
Forks
44
PR merge metrics
No merged PRs in 30d

Description

[Sample Data](https://drive.google.com/file/d/1TlHlixXaKTOtpPTNgc4fqC8b3tFk0g6J/view?usp=sharing)

When using `Image > Adjust > Threshold...` and selecting `Yen` to get the ImageJ 1.x threshold on a test image, we get:
![image](https://user-images.githubusercontent.com/1123809/109817155-33bb8d00-7bf7-11eb-95a0-ebe0a798e7cf.png)

Running a simple groovy script to threshold with ops
```
#@ OpService ops
#@ ImgPlus inputData

return ops.threshold().yen(inputData)
```
on the same image produces a much more aggressively thresholded image:
![image](https://user-images.githubusercontent.com/1123809/109817378-7ed5a000-7bf7-11eb-8994-d039ca978293.png)

I don't think this is just a different in image type because if I convert the image to 8-bit and run the IJ1 auto threshold it's actually even more generous:

![image](https://user-images.githubusercontent.com/1123809/109817714-d6740b80-7bf7-11eb-83aa-1011818714ae.png)

However I can produce a similar image in the IJ1 auto threshold by operating on the 16-bit image and turning up the `minValue` cutoff:
![image](https://user-images.githubusercontent.com/1123809/109817905-0de2b800-7bf8-11eb-9c63-265ab77474e8.png)

It looks like the issue is that Ops is computing the min/max for the histogram off the 16-bit input but then always converts the output to 8-bit, resulting in a too-high threshold.

First converting the test image to 8-bit and then running the above script results in a reasonable output:
![image](https://user-images.githubusercontent.com/1123809/109819988-32d82a80-7bfa-11eb-8a57-6d0491d93c47.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the mismatch using Image > Adjust > Threshold... with Yen, the linked sample image, and the ops.threshold().yen(inputData) Groovy script. Compare the 16-bit and 8-bit outputs with ImageJ 1.x, then trace how the Yen histogram range and output type are handled. Done means the ops result matches the ImageJ 1.x threshold on the sample image.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.