Get an homogeneous background for better thresholding results#13
Get an homogeneous background for better thresholding results#13remi-pr wants to merge 1 commit intojlsutherland:masterfrom
Conversation
|
Thanks for this @remi-pr! Very interesting. I can't wait to try it out and merge this in. An initial thought off the top of my head is version compatibility. We've seen a few issues with opencv versioning, e.g. #6. We want the package to work on both v2 and v3 opencv. What version of opencv are you working with? |
|
That is a very good point @jlsutherland . I indeed work with a quite old version of OpenCV ( The only cv2 call I use in the added code is |
|
Awesome. Thank you for looking into this. Testing in a few minutes. |
The idea is to get a flat and white background before thresholding.
For this a matrix of offsets is added to the image.
This matrix is optimized is order to
The optimization quality is not so critical, it does not need to converge (given the default parameters) to provide nice results. This can certainly be tuned further.
This is done on a down-scaled version of the image (for speed reasons). The matrix is then up-scaled to be applied to the original image.
It has been tested only on a few images where it showed promising results.
The added code is almost completely separate from the original code: 3 more functions in
page.pyand one function call before thresholding inprocess_skewed_crop