-
Notifications
You must be signed in to change notification settings - Fork 10
get_threshold enhancement #2
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needednew-contributorsup-for-grabs
Description
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needednew-contributorsup-for-grabs
get_threshold()is the function that should find the optimal value for the subsequent use ofcv2.threshold(). Currently it considers the lowest section of the document (since that part is usually white), and appliescv2.threshold()with descending values from 200, stopping as soon as the threshold is low enough that 99.9% of the pixels in the section are set to white. If the brightness of the picture is sufficiently uniform, the result is pretty good, otherwise some parts of the document become unreadable or completely black.Also, if that lowest section isn't supposed to be white, the function can't work.
If you have any ideas, please write a comment or submit a pull request, and if you would like to contribute but you don't understand some parts of the code, don't hesitate to ask.
EDIT:
Right now I'm combinig my custom function
get_thresholdwith OpenCV'scv2.adaptiveThresholdusing acv2.bitwise_orbetween the two, so that if a pixel is made white by either of the functions it will be white in the result. This improves performances significantly, but there are still problems with pictures that have non-uniform illumination.