Scanning image from prints comes with several specific problems. Correcting them is essential to get the image close as possible to the original material.


A common problem when scanning files is small deformations that can occur if the scanned material is not flat during the scanning. These deformations can be of two types, affine (rotation) or perspective (shearing).


Correcting these deformations can be done by finding four points of reference in the image and mapping them to their original coordinate. The tricky part is finding these four points with pixel accuracy. In our case, we detect four corners based on color landmarks consistent between scanned documents from a binarized version of the image using a specific color range selection.