Sunday, August 30, 2009

Stitching Together Scanned Images

Recently, I was scanning a lot of legal sized documents, but my scanner could only scan A4 sized paper. So I had to scan each document in parts and then stitch them together afterwards.

There is lots of software available for stitching together photos into a panorama, but surprisingly, I had trouble finding software for stitching together flat images (or for creating a "linear panorama" as some people call it) even though this task would supposedly be a little bit easier than making panoramas. Of course, it's possible to manually load up the images into a paint program and manually align them and blend them, but I had to stitch together a lot of documents, so this was too time-consuming for me.

In the past, I've used software like Hugin, Panotools, or Autostitch for stitching together photos, but I could never quite get the various tutorials on how to handle linear panoramas to work quite right.

I own a copy of Photoshop Elements 6.0, which does contain algorithms for this sort of stitching (under File...New...Photomerge Panorama). Initially, I was quite pleased with the results, but after inspecting the final stitched images more carefully, I began to realize that the algorithm had lots of problems rotating images in order to get good alignment between them. If you only superficially inspect the final result, everything seems fine because Adobe seems to use some sort of fancy blending algorithm (something like Enblend) that hides a lot of these imperfections. Unfortunately, the blending algorithm can't hide the fact that because of poor alignment, lines that should be straight aren't. Even when you manually rotate the images to help the alignment algorithm, Photoshop Elements doesn't help you try to fine-tune the rotation or positioning afterwards, so it's hard to get things aligned quite right (I was hoping that if I could get things close to alignment, the algorithm would "snap" things to the best position). Adobe is always tweaking their algorithms, so it's possible that later versions of Photoshop Elements give better results though.

In the end, I actually found a research tool from Microsoft that provided excellent automated results. Even better, Microsoft's Image Composition Editor was very fast and very easy to use, so I highly recommend this program. Eventually, I hope to figure out what I was doing wrong with Hugin because it's always useful to have an alternative that supports a lot of manual tweaking, but so far the results of the Image Composition Editor have been so good that I've only needed to resort to alternate tools (i.e. Adobe Photoshop Elements) only once, which occurred when I was stitching four images together that had only a small amount of overlap.


  1. Thank you very much. It's very helpfull

  2. WOW! I took your advice and used the Microsoft application to stitch together large electrical schematics that I scanned and it worked FLAWLESSLY! PERFECT PROGRAM!

    Before that I spent an hour trying to manually stitch the images together in a graphics program and nothing was lining up right, so I decided to search for a program that would do it for me and my search brought me here. The program stitched the images together in 15 seconds! Saving me hours of work since I have multiple documents to digitize.


  3. I too have some oversized documents to stitch and the program did the job in seconds without human intervention. My problem though is that the quality of immage of resulting file is very poor comparing to originals.

  4. There will inevitably be some image quality loss when the program needs to rotate and distort the images to get them to line up. There might be various configuration parameters in the program to limit the image loss, but I haven't played with them myself. Just to be safe, I always scanned my documents at a much higher resolution than I needed so that the loss in image quality wouldn't be too noticeable.

  5. Thank you very much. You saved me a lot of time seeking for an easy tool. I tried other panorama tools as well but this one was awsome.

  6. i spent AIONS to find something that work. Can't thank you enough!!!

    after wasting hours with hugin (which is perfect for photo panoramas) i was just amazed to find out that there was something like this!!! I cannot thank you enough!

    i am taking pictures of whole maps first and then smaller and smaller regions of map (so i can have greater resolution) and ICE stitches it very good.

    Is it possible to do such thing with hugin by having "pyramids" of pictures?

  7. When I previously used Hugin to make some traditional photo panoramas, I think I was able to export the final result as a giant Photoshop file where each of the original images was a different layer, thereby allowing me choose how to mix everything together afterwards (I could put the high resolution stuff above the lower resolution images, giving a pyramid of pictures). I'm pretty sure Hugin also lets you choose different photo calibration parameters for each image too. I never got Hugin to work for linear panoramas though, so I'm not sure.

  8. Thanks for the great help. I had some scanned text documents in my native language (Urdu) and was using an A4 sized scanner for Legal sized papers. So I had to scan each page twice and stitch them together. I tried a couple of other programs also but after reading this blog, I installed the MS Application and it worked great. Not only that but I could even do so much more with it. Thanks again