We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The combination of contrast and binary does not really handle low-light images.
A better approach is in https://gist.github.com/tobytailor/421369, which is to find the minimum and the maximum and use the average as a threshold.
I replaced them with a single function:
function contrastBinary(data) { var min = 127 * 3; var max = 128 * 3; for (var i = 0, len = Image.width * Image.height * 4; i < len; i += 4) { var val = data[i] + data[i + 1] + data[i + 2]; if (val < min) { min = val; } else if (val > max) { max = val; } } var threshold = (max + min) / 2; for (var i = 0, len = Image.width * Image.height * 4; i < len; i += 4) { ave = (data[i] + data[i + 1] + data[i + 2]); if (ave < threshold) { data[i] = data[i + 1] = data[i + 2] = 0; } else { data[i] = data[i + 1] = data[i + 2] = 255; } data[i + 3] = 255; } }
The text was updated successfully, but these errors were encountered:
Added this an option in version update.
Sorry, something went wrong.
No branches or pull requests
The combination of contrast and binary does not really handle low-light images.
A better approach is in https://gist.github.com/tobytailor/421369, which is to find the minimum and the maximum and use the average as a threshold.
I replaced them with a single function:
The text was updated successfully, but these errors were encountered: