I have seen apps, and wondered how can I programmatically take a picture of image. Define how it needs to be transformed so that it looks parallel to camera and not skewed perspective wise.
Then combine multiple photos to create a pdf file. For example this app does it: https://play.google.com/store/apps/details?id=com.appxy.tinyscan&hl=en
I do not use books for such trivial things so sorry I can not recommend any (especially in English). What you need to do is this:
find main contours
ideally whole grid but even outer contour will suffice (in case no grid is present). You need to divide the contour into horizontal (Red) and vertical (Green) curves (or set of points).
sample contour curves by 4 "equidistant" points
as the image is distorted (not just rotated) then we need to use at least bi-cubic interpolation. For that we need 16 points (Aqua) per patch.
add mirror points to cover whole grid
on the image are mirrored (Yellow) points only for horizontal contours you should do this also for vertical contours (did not fit me in the image and did not want to enlarge resolution just for that) and also for the corner points so you got
6x6 control points. The mirror can be done linearly (like I did).
Now the transformation is done like this:
dst(x0,y0)of target image
x,y as parameter for cubic interpolation
xs,ys is target image resolution then:
Now cubic interpolation is usually done on parameter
t=u and control points
t=u-1.0 and control points
t=u-2.0 and control points
The same goes for vertical contours and
xi,yi as bi cubic interpolation of
(u,v). And copy pixel:
This is just nearest neighbor but you can also use bilinear for this ... As cubic curve I would use this polynomial.
The idea behind bi-cubic interpolation is easy. compute point corresponding to parameter
u on 4 horizontal contours. That will give you 4 control points for the final cubic interpolation in vertical direction and
v as parameter. Resulting coordinate is your source pixel position.
For more info see:
In case you do not have a grid use any info that can be used as one. For example lines of text can be considered a contour for this ...
©2020 All rights reserved.