An electronic device configured to implement a method of generating a corrected image from a distorted image depicting at least a planar page having a main marker and a plurality of subordinate markers, all said markers of said page being located at boundaries of the page defining vertexes of a first rectangle having a first nominal aspect ratio, the method comprising the following operations:
- a) locating, in said distorted image, positions of captured subordinate markers and of a captured main marker,
- b) determining a geometric transformation to map locations of corrected pixels of said corrected image corresponding to captured pixels of said distorted image,
- c) generating said corrected image containing said corrected pixels at the locations determined at step b),
- wherein the markers of two adjacent planar pages of said planar pages define a second rectangle having a second aspect ratio, in that said distorted image depicts two adjacent planar pages of a notebook or agenda, and in that said operation b) is carried out through the following steps:
- b3) generating an intermediate image of the two adjacent pages of said notebook or agenda throughout the following steps:
- for each captured page of said two adjacent pages, determining relative positions, in respect to said main marker, of subordinate markers belonging to said captured page and determining an upper edge line (AB;
- FB) joining two upper markers of the markers of said captured page, a lower edge line (CD;
- ED) joining two lower markers of the markers of said captured page, an outer edge line (AC;
- FE) joining two outer markers of the markers of said captured page, an upper side line (AF) joining two upper outer markers of the markers of said two adjacent pages, a lower side line (CE) joining two lower outer markers of the markers of said two adjacent pages, an upper cross-point (B) between the upper edge lines (AB, FB) of said two adjacent pages, a lower cross-point (D) between the lower edge lines (CD, ED) of said two adjacent pages, a knuckle line (BD) of said two adjacent pages passing through said upper cross-point (B) and said lower cross-point (D), an upper target point (G) as intersection point between said knuckle line (BD) and said upper side line (AF), a lower target point (H) as intersection point between said knuckle line (BD) and said lower side line (CE), said outer edge line (AC;
- FE) crossing said lower edge line (CD;
- ED) and said upper edge line (AB;
- FB) in correspondence of a lower outer marker (C;
- E) and of an upper outer marker (A;
- F), respectively,
- determining a central fixed transformation point (O) belonging to said knuckle line (BD) as the point at which the ratio between its distance (OD) from the lower cross-point (D) and its distance (OH) from the lower target point (H) equals the ratio between its distance (OB) from the upper cross-point (B) and its distance (OG) from the upper target point (G),
- for each captured page of said two adjacent pages, determining a respective outer fixed transformation point (X1;
- X2) belonging to the respective outer edge line (AC;
- FE) as the point at which the ratio between its distance (X1C;
- X2E) from the lower outer marker (C;
- E) and its distance (X1A;
- X2F) from the upper outer marker (A;
- F) equals the ratio between the distance (OD) of said central fixed transformation point (O) from the lower cross-point (D) and the distance (OB) of said central fixed transformation point (O) from the upper cross-point (B), and determining a respective fixed transformation segment (OX1;
- OX2) joining the central fixed transformation point (O) with the respective outer fixed transformation point (X1;
- X2), then, for each captured pixel (P) laying in a page area comprised between the respective fixed transformation segment (OX1;
- OX2) and the respective upper/lower edge line (AB/CD;
- FB/ED), determining a corresponding intermediate pixel (P1) according to an image stretching algorithm that keeps unchanged all points of said outer edge line (AC;
- FE) and all points of said fixed transformation segment (OX1;
- OX2) and that maps points laying in said page area so as to elongate said knuckle line to bring said upper/lower cross-point (B;
- D) into said upper/lower target point (G;
- H) and so as to transform said upper/lower edge line (AB;
- CD) into said upper/lower side line (AF;
- CE),
- determining said intermediate image containing said intermediate pixels of said two adjacent pages and a guiding quadrilateral composed of said upper side line (AF), of said lower side line (CE) and of said outer edge lines (AC, FE);
- and
- b4) determining locations of corrected pixels of said corrected image by processing pixels of said intermediate image with a perspective correction algorithm adapted to transform said guiding quadrilateral into a rectangle having said nominal second aspect ratio by taking as a reference side said outer edge line or said inner edge line and by adjusting the length of the other lines of the quadrilateral accordingly.