Results 1 to 2 of 2

Thread: Finding marks on scanned image for alignment

  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Finding marks on scanned image for alignment

    [The following question is probably not really Qt dependent - save that I am working with Qt, and QImage to be more specific.]

    I need to display an image that was scanned from some form.
    [The image is black/white: i.e. the scanner removed the underlying form and saved only the things written on it. Therefore the image is solely user input.
    This is done to reduce the amount of data to be stored.]

    I would like to display the image and show the form beneath it. This is no problem with Qt. The issue I need to solve now is:
    I would like to align the two images. (The scanned image usually is a bit translated/rotated as the paper is not always at the same spot etc on the scanner). On the form (and on the scanned image) are marks (in the corners are 'angles' |_, _|, ...)]. Therefore I need to determine the position of some 'marks' on the scanned image. With the position of two of these marks I can calculate the QTransform that will put the scanned image properly aligned back on top of the form.

    Short summary:
    user filled form
    (scanner) -> b/w image of user input [this image is always a bit shifted...]
    now: image of form + scanned image => image of the filled form that was the original input to the scanner
    Problem: Where exactly is the 'origin' of the scanned image?


    Are there (free?) libs that do this? Are there better ways than scanning for 'marks'?

    Best regards, thank you for your time,
    Christoph

  2. #2
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Finding marks on scanned image for alignment

    Caduel,

    Sounds like an image registration problem. There exist libraries for doing this, but if I were you, I'd implement a simple registration algorithm yourself - that way you know exactly what's going on.

    1. Iterate over a collection of rotations and translations. Choose the range based on the extent of transformations you wish to correct.

    2. For each rotation/translation pair, apply the transformation to your image and compute the cross-correlation of the transformed image with some template image (containing only the markers). Instead of cross-correlation, you can simply use the sum of the product of the pixel intensities.

    3. Pick the rotation/translation pair that results in the highest correlation.

    JM

    Quote Originally Posted by caduel View Post
    [The following question is probably not really Qt dependent - save that I am working with Qt, and QImage to be more specific.]

    I need to display an image that was scanned from some form.
    [The image is black/white: i.e. the scanner removed the underlying form and saved only the things written on it. Therefore the image is solely user input.
    This is done to reduce the amount of data to be stored.]

    I would like to display the image and show the form beneath it. This is no problem with Qt. The issue I need to solve now is:
    I would like to align the two images. (The scanned image usually is a bit translated/rotated as the paper is not always at the same spot etc on the scanner). On the form (and on the scanned image) are marks (in the corners are 'angles' |_, _|, ...)]. Therefore I need to determine the position of some 'marks' on the scanned image. With the position of two of these marks I can calculate the QTransform that will put the scanned image properly aligned back on top of the form.

    Short summary:
    user filled form
    (scanner) -> b/w image of user input [this image is always a bit shifted...]
    now: image of form + scanned image => image of the filled form that was the original input to the scanner
    Problem: Where exactly is the 'origin' of the scanned image?


    Are there (free?) libs that do this? Are there better ways than scanning for 'marks'?

    Best regards, thank you for your time,
    Christoph

  3. The following user says thank you to magland for this useful post:

    caduel (23rd September 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.