Overview
A program to rectify or transform an image that contains a quadrilateral object into a 8.5 x 11 aspect ratio image.
Responsibility
- Wrote all the functions to process the image rectification, i.e., edge detection, 2d hough generation, intersection calculation, rectification formula, etc.
Relevant Line Identification
The 2D Hough transform has 180 rows (for degrees) and 2 * d columns, where d is the diagonal on the polar coordinate system. To select the relevant lines, I identify the set of local maxima with a threshold and also set the theta, rho, and length thresholds to group parallel lines into two categories.
The local maxima threshold is 0.20 * (maximum value in the Hough histogram). All locations below this threshold are ignored when finding local maxima.
The theta threshold is 45 degrees. Two lines are considered parallel if the absolute value of the difference in their angles on the 2D Hough transform is less than this threshold.
The rho threshold is d/4. It is used to check that the difference in rho between two locations on the 2D Hough transform is greater than this threshold. If two lines have similar angles (theta) and rho values, they are considered parallel lines in the same cluster on the 2D Hough transform, meaning they are very close to each other. If two lines have similar angles but different rho values, they are considered parallel lines from different clusters on the 2D Hough transform, indicating they are far apart.
The length threshold is 0.2 * (average length of the two parallel lines). Two lines are considered parallel if their lengths are similar in size and they also meet the theta and rho threshold requirements.