JPEG photo scan of paper text - How to enhance?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
feelart
Posts: 16
Joined: 2013-07-09T08:08:24-07:00
Authentication code: 6789

JPEG photo scan of paper text - How to enhance?

Post by feelart »

Hello,

Like many people, sometimes I use a smartphone or a camera, to readily have a scan of document (and in pratice even if you have time you'll never properly scan it later) or because it's too big to fit in a scan.

Code: Select all

convert -sharpen 2 -depth 8 photoOfNotes.jpg digitalizedNotes.jpg
does a pretty good job, but I believe it should be possible to automate futher compression and/or enhance of the source jpeg photo scan, to either jpeg or png.

The objective being
1/ "sharpen" the text and graphics (somethimes not all the text is well focused, for instance focus was on the bottom's text, but top is slightly blurred)
2/ compress
3/ have a rather uniform colour paper background (usually artificial source light is from one side of the paper and so has a darker area)

Often source document are grayscale, or with limited colours (for instance you used 3-4 pens to write on a draw board chart and want to keep a digital version of your work).

Thanks for your suggestions.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG photo scan of paper text - How to enhance?

Post by fmw42 »

What you are suggesting can be a difficult thing to achieve due to the perspective changes and lighting. It would be best if you can provide a link to an example or two of your images. That would make it easier to try to suggest things that might work.
feelart
Posts: 16
Joined: 2013-07-09T08:08:24-07:00
Authentication code: 6789

Re: JPEG photo scan of paper text - How to enhance?

Post by feelart »

As quick non private example:
http://hpics.li/2060cb8
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: JPEG photo scan of paper text - How to enhance?

Post by fmw42 »

I ran 5 iterations of -enhance to remove noise, then my textcleaner script (see link below -- unix bash shell script), based upon the IM -lat function. My script, noisecleaner, will do as many iterations of enhance as you want.

convert 794269scanTest1.jpg -enhance -enhance -enhance -enhance -enhance 794269scanTest1_enh5.jpg
textcleaner -g -f 20 -o 5 -s 2 794269scanTest1_enh5.jpg 794269scanTest1_enh5_f20_o5.jpg

http://www.fmwconcepts.com/misc_tests/t ... _o5_s2.jpg
Post Reply