Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yen threshold differs from IJ1 #636

Open
hinerm opened this issue Mar 3, 2021 · 4 comments
Open

Yen threshold differs from IJ1 #636

hinerm opened this issue Mar 3, 2021 · 4 comments

Comments

@hinerm
Copy link
Member

hinerm commented Mar 3, 2021

Sample Data

When using Image > Adjust > Threshold... and selecting Yen to get the ImageJ 1.x threshold on a test image, we get:
image

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

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

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

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

@hinerm
Copy link
Member Author

hinerm commented Mar 3, 2021

Note however that performing the conversion with ops produces yet a different result:

#@ OpService ops
#@ ImgPlus inputData

converted = ops.convert().int8(inputData)
return ops.threshold().yen(converted)

image

@imagejan
Copy link
Member

imagejan commented Mar 4, 2021

You should convert to unsigned 8-bit when converting with ops, no?

converted = ops.convert().uint8(inputData)

@hinerm
Copy link
Member Author

hinerm commented Mar 4, 2021

You should convert to unsigned 8-bit when converting with ops, no?

@imagejan honestly I don't know. Here's uint8 version - it just looked even farther from the IJ1 version:

image

@imagejan
Copy link
Member

imagejan commented Mar 4, 2021

Ah yes, that's because convert doesn't scale the intensity values at all, and high values simply "wrap around" the 8-bit limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants