# Removing gutter shadows from scanned pages

I am new to image processing, and I was hoping someone might set me in the right direction. I am trying to create a simple toolkit for personal use for digitizing scanned book images into a database. I managed to figure out how to detect and extract rectangular images from a scanned page with Mathematica, but as expected, I'm running into problems with gutter (spine) shadows distorting my thresholds.

I found a couple papers that describe potential algorithms for removing gutter shadows, but the math is a bit beyond me (for now). I don't have time to figure it out at the moment, so I'll be doing the current batch of images by hand, but I wanted to share this quandary with you guys, as this seems like a challenge some of you might enjoy.

Here are some relevant articles:

I'm hesitant to share sample images due to copyright restrictions, but here are two pages meant for the dataset I had in mind:

Here is a more typical two-page scan:

There are other variations to the problem, such as grainy gutters, gutters with uneven shadows, blurry gutters, gutters on dark backgrounds, gutters on colored backgrounds, etc. For the time being, however, let's assume that the source images are high-quality and that the scan was done with care.

Thank you and good luck!

• Does this help? mathematica.stackexchange.com/q/17125/8 – Verbeia Apr 24 '15 at 6:58
• @blochwave Sorry, this slipped through the cracks. I don't think it is prudent to close this question, since an answer to it would benefit the book scanning community in general, not just me. I'll go ahead and edit the question with sample images immediately. – Illya Moskvin Sep 28 '15 at 8:41
• This answer from halirutan is one of a few I've seen on this site about removing/fixing the lighting in an image - maybe it will help get started mathematica.stackexchange.com/a/11442/13162 – dr.blochwave Sep 28 '15 at 9:48
• if you have mathematica 10.0. you may try RemoveBackground[img, {"Background", {LightYellow, 0.5}}] – s.s.o Sep 28 '15 at 10:58
• – s.s.o Sep 28 '15 at 11:09

This has already been mentioned in a comment, so if you have access to Mathematica version 10 then the recently-introduced function RemoveBackground[] is very handy.

Example 1 with a light yellow background, as provided by s.s.o in a comment above.

image = Import["http://i.imgur.com/aIU3zCH.jpg"];

image = Import["http://i.imgur.com/9ZQ0lQt.jpg"];