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

Level does not work for some image #585

Open
aplhk opened this issue Mar 14, 2022 · 0 comments · May be fixed by #586
Open

Level does not work for some image #585

aplhk opened this issue Mar 14, 2022 · 0 comments · May be fixed by #586

Comments

@aplhk
Copy link

aplhk commented Mar 14, 2022

The algorithm will skip processing when the factor is zero

if (factor[j] !== 0) {

Which seems to support the case when the image was untouched

if (min[i] === 0 && max[i] === image.maxValue) {
factor[i] = 0;

However the case that max == min is ignored and returns untouched image, which should return a black image instead

} else if (max[i] === min[i]) {
factor[i] = 0;
} else {
factor[i] = (image.maxValue + 1 - delta) / (max[i] - min[i]);
}
min[i] += (0.5 - delta / 2) / factor[i];

aplhk added a commit to aplhk/image-js that referenced this issue Mar 14, 2022
@aplhk aplhk linked a pull request Mar 14, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant