PDA

View Full Version : Finding marks on scanned image for alignment



caduel
22nd September 2007, 11:06
[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

magland
23rd September 2007, 02:10
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


[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