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

suggestion for additional parameter-tweaking-support #241

Open
musikdusche opened this issue Nov 30, 2020 · 2 comments
Open

suggestion for additional parameter-tweaking-support #241

musikdusche opened this issue Nov 30, 2020 · 2 comments

Comments

@musikdusche
Copy link

Dear OpenNoteScanner-Team,
I'm starting to use the program and it's conveniently simple and fine so far. Thank you very much for this piece of software!
But I'm having trouble getting good results, if the scanned document contains thick lines (for example a text on an A4-page with a felt-tip-pen or flipchart-marker). In this case you get an "edge-detection"-like effect.

I had a look into your source code and you are using the following function-call (two times in ImageProcessor.java):
Imgproc.adaptiveThreshold(mask,mask,255,Imgproc.ADAPTIVE_THRESH_MEAN_C,Imgproc.THRESH_BINARY_INV,15,15);

The last two values 15 and 15 are hardcoded into your source. If I am understanding the OpenCV-adaptiveThreshold parameters right, tweaking these two numbers should solve my problem. Would it be possible to make these two numbers configurable in the app-settings dialog? (I am not an app-dev myself so I have no idea if implementing this is a lot of work and thus too much to ask.)

Thank you very much for your work!

@allgood
Copy link
Owner

allgood commented Dec 1, 2020 via email

@musikdusche
Copy link
Author

But this can also cause another problem: thin lines will not be detected!

I am pretty sure this isn't true. From the OpenCV-docs concerning the two "15"-parameters in your code:

blockSize: size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on
C: constant subtracted from the mean or weighted mean. Normally, it is positive but may be zero or negative as well.

So, with blockSize you set certain neighbourhood-size. If that size is very big, you only get problems, if the backround-value changes are too big inside this neighbourhood - which won't be the case if you only take a neighbourhood 15 pixels wide on a 16Megapixel-smartphone photo.

What could happen is this:

  • a bigger neighbourhood means more computation (maybe it'll slow down the process seriously)
  • if you take a photo of a white paper on a dark table (and the paper-rectangle-recognition does not work), then (after applying the adaptiveThreshold) the paper-borders are thicker, because you need a bigger distance to have the neighbourhood placed completely inside the dark area.

Thank you for your patience and attention. Greetings from Düsseldorf, Germany.

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

2 participants