A computer-readable non-transitory recording medium storing an image inclination angle detection program causing a computer to function as:
- a first search point setting device that detects a plurality of characters included in an image acquired through document reading performed by an image reading device and sets a first search point at a point on each of the characters;
- a first search frame generator that sets, with respect to each first search point set by the first search point setting device, a plurality of first search circles with different diameters having the first search point as a center and generates a first search frame composed of the first search point, which is the center of the plurality of first search circles, and the plurality of first search circles;
- a first marking device that attaches first marks to points at which the plurality of first search circles intersect the characters included in the image in each first search frame generated by the first search frame generator;
- a line space region detector that extracts, in each first search frame, ranges having no first marks when viewed from the first search point, which is the center of the first search circles, in the form of fan shapes and detects a range having a largest central angle as a region present in a line space;
- a second search point setting device that sets second search points on any of the plurality of first search circles in the region detected by the line space region detector in each first search frame;
- a second search frame generator that sets, with respect to each second search point set by the second search point setting device, a plurality of second search circles with different diameters having the second search point as a center and generates a second search frame composed of the second search point and the plurality of second search circles;
- a second marking device that attaches second marks to points at which the second search circles intersect the characters included in the image in each second search frame generated by the second search frame generator;
- a line space direction setting device that extracts, in each second search frame, ranges having no second marks when viewed from the second search point, which is the center of the plurality of second search circles, in the form of fan shapes and sets, as a line space direction, a direction in which a straight line passing through the center portions of the ranges and the second search point extends;
- a clustering device that performs clustering by which the second search points of the second search frames arranged in the line space direction set by the line space direction setting device are set as a same class;
- an approximate straight line calculator that calculates, for each class set by the clustering device, an approximate straight line connecting the second search points of the second search frames in the class;
- a row direction calculator that, for each approximate line calculated by the approximate straight line calculator, obtains, based on positions of all pixels of characters overlapping with the second search circles from among a plurality of characters positioned immediately above the approximate line, a straight line indicating a direction of a row composed of the plurality of characters positioned immediately above the approximate line and further obtains, based on positions of all pixels of characters overlapping with the second search circles from among a plurality of characters positioned immediately below the approximate line, a straight line indicating a direction of a row composed of the plurality of characters positioned immediately below the approximate line;
- and
- an inclination angle determination device that determines, from inclinations of respective straight lines indicating the directions of the rows calculated by the row direction calculator, an inclination angle of the image with respect to the document, the image being acquired through document reading performed by the image reading device.