allgood / OpenNoteScanner

Android application for scanning and manipulating handwritten notes and documents.
Other
1.35k stars 283 forks source link

suggestion for additional parameter-tweaking-support #241

Open musikdusche opened 3 years ago

musikdusche commented 3 years ago

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 commented 3 years ago

This can possibly solve your problem... making them higher will produce thicker lines. But this can also cause another problem: thin lines will not be detected!

Will keep this open so I can put this on a parameter in the future.

Em seg., 30 de nov. de 2020 às 12:33, musikdusche notifications@github.com escreveu:

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!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ctodobom/OpenNoteScanner/issues/241, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOKDUHAZKLMXP5UKJ737YDSSO3LJANCNFSM4UHXJB2Q .

musikdusche commented 3 years ago

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:

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