Procedurally correcting for common "scan shading"

XnConvert Multi Platform - Windows, MacOSX, Linux
bdragon
Posts: 93
Joined: Mon May 01, 2017 8:06 am

Procedurally correcting for common "scan shading"

Postby bdragon » Sat May 27, 2017 5:49 am

I've got a lot of badly scanned stuff. When people did not outright take pictures of the drawing directly.

Usually There are these cases (from best scenario to to worst one):
- Scanned from a book, so most of the image is fine, but then there's a sharp "shading" in one of the edges, where the book was partially lifted from the scan by it's own binding.
- Taken a picture of, and while it was taken care to at least make it in a well lit room, there's still a linear gradient shading from one side to the other. And possibly some prospective perspective to correct.
- Taken a picture of, and in a badly lit room, so the flash kicked in, resulting in a circular gradient shade from an unknown point inside the image (usually near the top). And possibly some prospective perspective to correct.

Is there some way to do these corrections in batch?

Yes i could do them hand by hand, and probably get a very good result. But if i could just press a button and save me several hours of work for stuff i just do for leisure anyway and thus do not get paid... i could just correct the stuff that gets missed by XnConvert.

cday
XnThusiast
Posts: 1508
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Procedurally correcting for common "scan shading"

Postby cday » Sat May 27, 2017 2:24 pm

bdragon wrote:I've got a lot of badly scanned stuff. When people did not outright take pictures of the drawing directly.

It's a common problem, people launch into large scanning projects without spending any time learning how to produce good scans... :wink:

Usually There are these cases (from best scenario to to worst one):
- Scanned from a book, so most of the image is fine, but then there's a sharp "shading" in one of the edges, where the book was partially lifted from the scan by it's own binding.
- Taken a picture of, and while it was taken care to at least make it in a well lit room, there's still a linear gradient shading from one side to the other. And possibly some prospective perspective to correct.
- Taken a picture of, and in a badly lit room, so the flash kicked in, resulting in a circular gradient shade from an unknown point inside the image (usually near the top). And possibly some prospective perspective to correct.

Yes i could do them hand by hand, and probably get a very good result. But if i could just press a button and save me several hours of work for stuff i just do for leisure anyway and thus do not get paid... I could just correct the stuff that gets missed by XnConvert.

How would you produce the results you want by hand? It may be possible to reduce shading near the edge of a scan using a levels adjustment, or alternatively using a combination of contrast and brightness adjustments, but improvement is likely to be limited as the quality of the text on other parts of th epage is likely to be reduced. Similar considerations apply to trying to reduce uneven illumination of the image.

Is there some way to do these corrections in batch?

XnConvert provides a number of possible image adjustments in the Actions tab, equivalent to those available in XnView MP or XnView Classic, so the best thing would be to do some experiments in one or other of those programs and see what results you can obtain, then test to see to what extent any particular settings produce useful results when images are batch processed in XnConvert.

The overall situation you describe is common in book scanning, and so you might like to have a look at the DIY Bookscanner Forum.

Improving images with uneven illumination isn't easy with common image editing tools, but there is some software produced for book scanning that can produce a useful improvement: you might look at ScanTailor which is widely used by forum members for batch processing book scans, and there are also other tools mentioned.

Regarding curvature of text in photographed pages, some commercial camera-based scanners come with sophisticated software that can work well, but that software wouldn't be available separately. Recent commercial OCR software also includes processing functions for enhancing camera images to reduce distortion, and can also help with uneven illumination and other enhancements. Google have also quite recently made available freeware software intended for processing camera images of book pages that looked impressive in the review I saw, but I don't have any details.

Post some example images that you wish to enhance on the DIY Bookscanner forum!

bdragon
Posts: 93
Joined: Mon May 01, 2017 8:06 am

Re: Procedurally correcting for common "scan shading"

Postby bdragon » Sat May 27, 2017 2:53 pm

Up until now i've corrected by dumbly applying a gradient of white ( circular or linear) and then tweaking contrast and gamma on the resulting image. Possibly hand selecting regions to apply more contrast/gamma.

I have nothing that adjusts gamma in a gradient fashion.

Also i have never taken a class studying how to do this stuff. So the results are not great (often times too little contrast) and also i am not picky at all. I just need something readable to pass to an ocr or to present around without saying it came from a picture.

Bad for worst i convert it to black and white and start removing artifacts by hand.

^_^;

Did i say i do this for leisure and not for work thus i'm ignorant on how to do it properly?

cday
XnThusiast
Posts: 1508
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Procedurally correcting for common "scan shading"

Postby cday » Sat May 27, 2017 3:08 pm

bdragon wrote:Up until now i've corrected by dumbly applying a gradient of white ( circular or linear)...

Using XnView software, how do you do that?

... Possibly hand selecting regions to apply more contrast/gamma.

One of the limitations of batch processing, of course, is that it isn't possible to apply specific user actions.

I just need something readable to pass to an ocr or to present around without saying it came from a picture.

Do you have one of the recent commercial OCR programs like Abbyy FineReader, Nuance Omnipage or Adobe Acrobat?

I guess not, otherwise it would be worth trying more or less going directly to that and using the enhancements available, if your main aim is to extract the text? There may be a trial version of Abbyy FineReader available for download if you have a look.

bdragon
Posts: 93
Joined: Mon May 01, 2017 8:06 am

Re: Procedurally correcting for common "scan shading"

Postby bdragon » Sat May 27, 2017 3:16 pm

Most of the times i just need the graphs.

Rarely i actually need the text and resort to ocr only if i would have to copy an entire page. I mean, most of the scans i get is 300 dpi (remember: the scans are not made by me). If it's not a picture (those are between 8 and 10 mpx). Ocr with that kind of definition is just barely better than rewriting everything by hand.

Also no i do most of the corrections via gimp.

But i've already seen that (for my very low standards) just applying the white gradient is often enough to then pass it to xnconvert for a batch gamma/contrast pass.

And then a possible binary conversion after that if it's really needed.

It's just that applying a circular or linear gradient takes time to adjust it well enough.


Return to “XnConvert”

Who is online

Users browsing this forum: No registered users and 2 guests