In RF5, the CPU 40 determines whether the variance value HLDV calculated in RF4 is smaller than or equal to a predetermined variance value. If the variance value HLDV is smaller than or equal to the predetermined variance value HLDV (RF5: YES), the CPU 40 proceeds to RF6. If the variance value HLDV is greater than the predetermined variance value HLDV (RF5: NO), the CPU 40 proceeds to RF7. The predetermined variance value may be, for example, 0.005. With the predetermined variance value being set at 0.005, even when an edge position EP from the lateral end of the original sheet GS is erroneously recognized as the linear edge position LEP, the leading-end line HEL may calculate the leading-end line HEL based on an alternative linear edge position LEP between the most upstream leading-end position UHP and the central pixel position adopted in RF9 (see below) or an alternative linear edge position LEP between the central pixel position and the most downstream leading-end position DHP adopted in RF8 (see below) so that the leading-end line HEL may be obtained accurately without the influence of the edge position EP from the lateral end of the original sheet GS.
In RF6, the CPU 40 calculates the leading-end line HEL based on the linear edge positions LEP. In particular, the CPU 40 may apply the least square method to each liner edge position LEP extracted in RF1-RF3 to obtain the leading-end line HEL. The leading-end line calculating process RA4 ends at the end of the process in RF6.