It is currently Thu Jun 04, 2026 7:30 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 2:19 pm  (#1) 
Offline
GimpChat Member

Joined: Oct 17, 2013
Posts: 5
Good day,

I have thousands of old, scanned maps that a client wants to mosaic and color-balance. I'm fine with the mosaic piece, but have no idea how to batch color-match all of these thousands of images. Any help would be much appreciated!

Here's an example of what I'm dealing with...two maps that need to be placed side by side, but the paper is a different shade. I could probably match these two by hand, but not thousands of them.

Image

Thanks,
Shawna


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 3:13 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Convert them all to grayscale, and then perhaps recolor them and/or add paper texture back. Here:
- desaturate
- Curves on each to make the paper white
- Purple layer in multiply mode
- RGB noise layer in multiply mode

Attachment:
ScannedDocuments.jpg
ScannedDocuments.jpg [ 225.38 KiB | Viewed 6654 times ]

_________________
Image


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 3:19 pm  (#3) 
Offline
GimpChat Member

Joined: Oct 17, 2013
Posts: 5
Thanks- but can you do that in a batch? I don't want to edit curves on thousands of these things if I can avoid it.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:30 pm  (#4) 
Offline
GimpChat Member

Joined: Sep 22, 2013
Posts: 27
Well desaturation itself should remove any color-cast differences, wouldn't it? Then you can apply unsharp mask or similar sharpening tool.
This should be quite easy to script in imagemagick...

Imagemagick aslo provides 'level' adjustment, this might be also used...

Of course if you want to rotate these map and align them in some way, this would be quite a problem to automatize...


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:36 pm  (#5) 
Offline
GimpChat Member

Joined: Oct 17, 2013
Posts: 5
I wish the desaturation would remove the color-cast differences, but you can see the images still have differences in the background color.

The image on the left looks pretty decent and has a bright background, but the one on the right is a fairly dark grey background.

The rotation and alignment is actually easy - because I'll use mapping software (ESRI ArcGIS Desktop) and just georeference them all (tie them down to a one-mile square grid). They'll end up being a basemap of sorts for the client.

I'll check out Imagemagick. Thank you.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:44 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Apr 08, 2010
Posts: 5420
Location: Northwest Ohio
instead of desaturation, how about threshold? That makes it only black and white, no grey.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:47 pm  (#7) 
Offline
GimpChat Member

Joined: Sep 22, 2013
Posts: 27
A combination of two tresholds?

=EDIT=

You can set own color of paper this way


Attachments:
3182_STR-mod-green.PNG
3182_STR-mod-green.PNG [ 33.83 KiB | Viewed 6610 times ]
3182_STR-mod.PNG
3182_STR-mod.PNG [ 33.78 KiB | Viewed 6611 times ]
Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:53 pm  (#8) 
Offline
GimpChat Member

Joined: Oct 17, 2013
Posts: 5
You two are brilliant! I've never used threshold before. I typically just make maps not process imagery.

Thank you so much!


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 4:58 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: Apr 08, 2010
Posts: 5420
Location: Northwest Ohio
If you write down the exact numbers for the threshold arrows, then it will go quickly and you can always make adjustments if needed. Also, if that is the only filter you use for each pic, you might be able to 'reuse' the filter with the settings last used and that would be a bit of a shortcut.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Thu Oct 17, 2013 6:27 pm  (#10) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
It is highly unlikely that you can use a similar threshold on the various pics.... You have to find the right value where the background dirt disappears and the useful lines aren't eroded. If you use a script you can use brute force, though: make several runs on all pictures with a different threshold each time, and then check the outputs.

Threshold also makes the edges of things rather jaggy, so it's usable only of your pictures are in a higher definition than their final use (scaling down the picture will make the jaggedness much less visible)

_________________
Image


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Fri Oct 18, 2013 3:21 am  (#11) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2599
For batch processing OP might have to resort to Imagemagick

Image

Difficult to say with only the 2 examples but an IM command such as this will remap an image.

convert original.png  -dither NONE -remap reference.png result.png


Hopefully the background will map to white in all cases. I put in a couple of greys, but you could try fewer or more, or different colours altogether in the reference image. The form of a batch/bash file depends on OS.

Here is a challenge for the clever people. Something like shellout to operate on the current image with an IM command and send back to Gimp as a new layer or image.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Fri Oct 18, 2013 6:24 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 03, 2011
Posts: 1656
I've tried something different, with a G'MIC script. Not sure if it can apply to all images, but it has the advantage of only modifying the image contrast globally, and does not change the image content (no threshold or segmentation needed).

1. First, I compute the median color value for all images to 're-align'.
2. Second, I change the contrast (i.e. multiply) of images so that the resulting median color is the same for all images (taken from a reference image, the first one for instance).

Here is what I get (first row is the original images, second row has the second one modified to fit the color of the first one).

Attachment:
gmic_align_color.jpg
gmic_align_color.jpg [ 512.16 KiB | Viewed 3356 times ]


As a consequence, it keeps all the different shading present in the original images. Maybe it is not what you want.
Let me know, I could do a G'MIC filter for the GIMP plug-in if necessary.


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Fri Oct 18, 2013 9:33 am  (#13) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
My histogram match script http://silent9.com/blog/archives/162-GI ... Match.html can do this (HSV matching):

Attachment:
match.jpg
match.jpg [ 89.84 KiB | Viewed 3337 times ]


I'd have to create a little batch wrapper script around it to match all images in a directory to one specific image. Results are similar to what Ron got with gmic.

Processing is a bit slow - about 20 seconds per image on my laptop.

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: Old scanned document restoration?
PostPosted: Fri Oct 18, 2013 10:04 am  (#14) 
Offline
GimpChat Member

Joined: Oct 17, 2013
Posts: 5
RobA - I think the histogram match script would work well for my purposes. I played with the threshold a bunch last night and it works well for some images, but I'm losing some of the pencil marks on other images.

I'll download your script and try it on more images to see what results I get.

Thanks everyone!


Top
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group