Page 1 of 1
Good way to remove grey background from (scanned) pictures?
Posted: Fri Jun 05, 2015 2:52 pm
by Little John
Hi all,
in scanned pictures (e.g. pages from textbooks) sometimes there is a gray background.
Or in the following example, the only photo-copy I had available for scanning was of poor quality:
Especially for the picture above, I didn't find a way to improve the quality, i.e. make the text in the boxes good readable.
I tried with Faststone Image Viewer and Paint.net, using all functions that I found for changing the contrast etc., but to no avail.
Does someone of you know a way to make the text better readable?
Maybe a special (free) program, or perhaps a clever algorithm written in PureBasic?
I think an appropriate algorithm based on wavelets might do the trick, but currently I don't know enough about wavelets for writeing such a program myself.
Thanks in advance for any suggestions that point into the desired direction.
Re: Good way to remove grey background from (scanned) pictur
Posted: Fri Jun 05, 2015 3:07 pm
by TI-994A
Hi Little John. If the original is already of such quality, like the example you posted, I'm not sure.
But if you're scanning in from textbooks, as you said, increasing the brightness and decreasing the contrast settings on the scanner itself might improve the results. It usually works for me when scanning documents with coloured backgrounds.
Re: Good way to remove grey background from (scanned) pictur
Posted: Fri Jun 05, 2015 3:19 pm
by Michael Vogel
I tried some effect functions in paintshop pro, but the results are not that good...
Remove Artefacts
Lighter/Darker

Re: Good way to remove grey background from (scanned) pictur
Posted: Fri Jun 05, 2015 4:33 pm
by Little John
Michael Vogel wrote:I tried some effect functions in paintshop pro, but the results are not that good...
Many thanks for trying!
Your results look pretty much like the results that I got ... not really satisfying.
I hope that there is a better solution.
Thanks again.
Re: Good way to remove grey background from (scanned) pictur
Posted: Fri Jun 05, 2015 4:39 pm
by Kukulkan
I would try to use simple curves to set a threshold for the WhitePoint. Should not be that hard to implement but I believe you need to find a method to determine the right threshold value.
But in my experience, it is mostly worth to try to get better scans. Some better scanners also have image enhancement algorithms who do a great job on such images directly during scanning. Eg, try to find some OCR enhancements in your scanner software.

Re: Good way to remove grey background from (scanned) pictur
Posted: Fri Jun 05, 2015 5:53 pm
by IdeasVacuum
If the example is representative, then PB could maybe help reverse-engineer the diagram to re-draw it.
1) Use Point() to find all the jet-black pixels. There will be a lot of "noise" but the text could be good enough to
2) Use Character Recognition to store the text as text. (OCR).
3) Use Point() to find all the background pixels (white?). Plot them onto a canvas that is pre-coloured with the colour of the diagram boxes.
Re: Good way to remove grey background from (scanned) pictur
Posted: Sat Jun 06, 2015 6:22 am
by sancho2
I think a decent smart phone camera will do a better job of "scanning" the photocopy you had. If you have to scan then a color scanner will be better than a black and white, as it won't try to shade non-white areas.
Re: Good way to remove grey background from (scanned) pictur
Posted: Sat Jun 06, 2015 10:28 pm
by davido
@Little John,
Perhaps there is a suitable algorithm in OpenCV?
Re: Good way to remove grey background from (scanned) pictur
Posted: Sun Jun 07, 2015 1:50 pm
by Little John
Kukulkan wrote:I would try to use simple curves to set a threshold for the WhitePoint. Should not be that hard to implement but I believe you need to find a method to determine the right threshold value.
Thank you for looking into his issue, and for posting your result.
I have done something similar. The result is even a little better, when this method is applied separately to light and dark areas of the picture.
I'm now looking for a software or algorithm, that produces better results, by separating singnal from noise.
Kukulkan wrote:But in my experience, it is mostly worth to try to get better scans.
I agree. However, my main problem is currently that I have several poor black/white photo-copies, and the best scan that I can get is almost exactly like the photo-copy, i.e. it is poor as well, like the example that I posted.
Re: Good way to remove grey background from (scanned) pictur
Posted: Sun Jun 07, 2015 1:52 pm
by Little John
IdeasVacuum wrote:If the example is representative, then PB could maybe help reverse-engineer the diagram to re-draw it.
Thanks for the suggestion.
Unfortunately, the example is not exactly representative, i.e. the signal in the pictures is not always text.
Re: Good way to remove grey background from (scanned) pictur
Posted: Sun Jun 07, 2015 2:04 pm
by Little John
davido wrote:@Little John,
Perhaps there is a suitable algorithm in OpenCV?
Davido, many thanks for this suggestion!
I've also thought about OpenCV, but unfortunately I don't know much about it.
Something like this seems not to be covered by JHPJHP's "PureBasic Interface to OpenCV".
However, now I found an
interesting article, which seems to point into the right direction.
Thanks again!