Purpose
The script aims to correct the skew in scanned document images and align them properly for readability or further processing.
The Hough Line Transform method identifies straight lines in the image, which are used to calculate the skew angle.
Angle Calculation and Deskewing:
By analyzing the angles of the detected lines, the script calculates the median angle of skew.
The image is rotated based on this angle to achieve proper alignment.
Save the Output:
The deskewed and aligned image is saved to the specified output path.
Usage
The script is simple to use:
Specify the path to the input scanned document.
Provide a filename or path for the output deskewed document.
Run the script, and it automatically processes the document.
Error Handling
If the input image cannot be loaded, the script notifies the user.
It also handles cases where no lines are detected, which might occur with low-quality or blank images.
Expected Outcome
The output is a well-aligned, deskewed version of the input scanned document, ready for use in workflows like OCR, archiving, or printing.
Let me know if you need refinements or additional functionality (e.g., batch processing, handling rotated text).