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

MedianCut should scale all color values from [0, 248] -> [0, 255] #133

Open
noblemaster opened this issue Sep 27, 2021 · 0 comments
Open

Comments

@noblemaster
Copy link

I did some tests and MedianCut tends to make images darker because all colors besides white are with their last 3 bits set to '0'.

https://github.com/imagej/imagej1/blob/faaa7e0b29e91afff5cba11b8c0e700d9e976ea4/ij/process/MedianCut.java#L253-L254

The following replacement does a much better job:

// adjust values, i.e. we had the last 3 bits cut off: [0, 248] --> [0, 255]
r = (255 * r) / 248;
g = (255 * g) / 248;
b = (255 * b) / 248;

This also resets white to its original color.

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

1 participant