8

I've got a whole lot of scanned images (> 500) the majority of which were scanned with the paper not completely square. They need to be rotated about 1-5 degrees to be aligned again.

Is there any software that does this? I know some scanner drivers do but mine doesn't seem to.

Update: It seems that thing I want here might be Image Registration software.

quack quixote
  • 42,186
  • 14
  • 105
  • 129
AndrewR
  • 253
  • 2
  • 10
  • Fascinating question. Upvoted. I look forward to seeing what the accepted reply is. (I have no clue myself.) – Alex Mar 13 '10 at 07:07
  • Possible solution: http://www.hacktrix.com/fix-alignment-issues-in-scanned-documents – AndrewR Mar 15 '10 at 00:39
  • You are looking for "deskewing". Related questions with some answers: [#204230](http://superuser.com/q/204230), [#444901](http://superuser.com/q/444901). – tanius Feb 08 '15 at 13:03

2 Answers2

2

Imagemagick can handle batch processing, including rotation. Of course you'll need to know which image needs what amount (1-5 degrees) of rotation. You could either rotate all by 1 degree and then review for a further one degree, or check all at the start and put in folders of rotation amount.

-rotate degrees{<}{>} Apply Paeth image rotation (using shear operations) to the image.

Use > to rotate the image only if its width exceeds the height. < rotates the image only if its width is less than the height. For example, if you specify -rotate "-90>" and the image size is 480x640, the image is not rotated. However, if the image is 640x480, it is rotated by -90 degrees. If you use > or <, enclose it in quotation marks to prevent it from being misinterpreted as a file redirection.

outsideblasts
  • 6,455
  • 1
  • 18
  • 19
0

You can use package deskew in python.

  1. Install the packege
pip install deskew
  1. Use it
import numpy as np
import skimage
import deskew


image = skimage.io.imread('input.jpg')
grayscale = skimage.color.rgb2gray(image)
angle = deskew.determine_skew(grayscale)
rotated = skimage.transform.rotate(image, angle, resize=True) * 255
skimage.io.imsave('output.jpg', rotated.astype(np.uint8))

https://github.com/sbrunner/deskew

Sajjad Aemmi
  • 101
  • 3