{"id":13415738,"url":"https://github.com/kakul/Alyn","last_synced_at":"2025-03-14T23:31:04.231Z","repository":{"id":57410026,"uuid":"60898958","full_name":"kakul/Alyn","owner":"kakul","description":"Detect and fix skew in images containing text","archived":false,"fork":false,"pushed_at":"2019-04-04T11:56:27.000Z","size":44287,"stargazers_count":261,"open_issues_count":16,"forks_count":79,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-01T11:08:38.205Z","etag":null,"topics":["deskew","image-deskew","image-processing","matplotlib","numpy","pypi","rotate","scikit-image","text"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kakul.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-11T08:55:54.000Z","updated_at":"2024-09-19T02:19:13.000Z","dependencies_parsed_at":"2022-08-24T19:00:43.704Z","dependency_job_id":null,"html_url":"https://github.com/kakul/Alyn","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakul%2FAlyn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakul%2FAlyn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakul%2FAlyn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakul%2FAlyn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kakul","download_url":"https://codeload.github.com/kakul/Alyn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243663436,"owners_count":20327299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deskew","image-deskew","image-processing","matplotlib","numpy","pypi","rotate","scikit-image","text"],"created_at":"2024-07-30T21:00:51.744Z","updated_at":"2025-03-14T23:31:03.354Z","avatar_url":"https://github.com/kakul.png","language":"Python","funding_links":[],"categories":["2. \u003ca name='DeskewingandDewarping'\u003e\u003c/a\u003eDeskewing and Dewarping","Deskewing and Dewarping"],"sub_categories":["1.4. \u003ca name='OCRCLI'\u003e\u003c/a\u003eOCR CLI"],"readme":"# Alyn\n\n[![PyPI version](https://badge.fury.io/py/alyn.svg)](https://badge.fury.io/py/alyn)\n\n## Skew detection and correction in images containing text\n\n\u003cimg src=\"/examples/4.jpg\" width=400px\u003e\u003c/img\u003e\n\u003ch5\u003eImage with skew\u003c/h5\u003e\n\u003cimg src=\"sample_output.jpg\" height=300px\u003e\n\u003ch5\u003eImage after deskew\u003c/h5\u003e\n\n### Install and use via pip!\n\nRecommended way(using virtualenv):\n\n1. `mkdir alyn-test`\n2. `cd alyn test`\n3. `mkvirtualenv .`\n4. `pip install alyn`\n5. `source bin/activate`\n\n#### To detect skew angle in image:\n\n```\nfrom alyn import SkewDetect\nsd = SkewDetect(\n\tinput_file='path_to_file',\n\tbatch_path='optional_batch_processing_path',\n\toutput_file='optional_text_file_output_path',\n\tdisplay_output='Yes/No')\nsd.run()\n```\n\n##### Extra options:\n\n* `sigma`:canny edge detection blurring\n* `plot_hough`: display hough lines detected\n* `num_peaks`: control the number of hough line peaks\n\n#### To deskew image:\n\n```\nfrom alyn import Deskew\nd = Deskew(\n\tinput_file='path_to_file',\n\tdisplay_image='preview the image on screen',\n\toutput_file='path_for_deskewed image',\n\tr_angle='offest_angle_in_degrees_to_control_orientation')`\nd.run()\n```\n### Requires\n\n* `numpy`\n* `matplotlib`\n* `scipy`\n* `scikit-image`\n\n### Techniques used\n\n* Canny Edge Detection\n* Hough Transform\n\n### Features\n\n* Detect the skew in given images\n* Display the output \n* Save the output to txt file\n* Batch process files in a directory\n* View Hough Transform of a given image\n* Set the number of peaks for Hough Transform and Sigma for Canny Edge detection\n* Rotate the image to remove the skew\n\n### How the skew detection works\n\nThe skew detection script takes image file as input, then performs the following steps:\n\n* Converts the image to greyscale\n* Performs Canny Edge Detection on the Image\n* Calculates the Hough Transform values\n* Determines the peaks\n* Determines the deviation of each peaks from 45 degree angle\n* Segregates the detected peaks into bins\n* Chooses the probable skew angle using the value in the bins\n\nThe deskew script uses the skew angle determined using skew detection script to remove the skew from the image.\n\n### Using scripts directly(older method)\n\n#### Image skew calculation using skew_detect.py\n\nTo calculate the skew angle for a given image file, use `-i` option followed by the path to file:\n\n\t./skew_detect.py -i image.jpg\n\nTo save output in a text file add `-o` option followed by the output file name:\n\t\n\t./skew_detect.py -i image.jpg -o output.txt\n\nTo display output information add `-d` option followed by a string `Yes`:\n\t\n\t./skew_detect.py -i image.jpg -d Yes\n\nTo batch process files in a directory, use `-b` option followed by the path to directory:\n\t\n\t./skew_detect.py  -b examples\n\nTo display Hough Transform plot for an image,:\n\t\n\t./skew_detect.py -i image.jpg -p Yes\n\n##### Output of the Hough Transform:\n\n\u003cimg src=\"hough.jpg\" width=\"400px\"\u003e\t\n\nTo set the value of sigma for Gaussian blurring in Canny Edge Detection,  use `-s` option followed by the desired value:\n\t\n\t./skew_detect.py -i image.jpg -s 3\n\nTo set the number of peaks collected from Hough Transform, use `-n` option followed by the desired value:\n\n\t./skew_detect.py -i image.jpg -n 10\n\n### Image Deskew using deskew.py\n\nTo perform a simple deskew and display the output:\n\t\n\t./deskew.py -i image.jpg -d Yes\n\nTo save the deskewed image, use the following:\n\n\t./deskew.py -i image.jpg -o rotated.jpg\n\nIn some cases the result image might be upside down or the text may be running vertical, To fix this, use `-r` followed by the desired angle in `int`:\n\t\n\t./deskew.py -i image.jpg -o rotated.jpg -r 90\n\nTo generate data for experimental purposes, run the test_img_gen.py in test_data folder. This will generate images containing a white line having angle between 0 to 180 degrees.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkakul%2FAlyn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkakul%2FAlyn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkakul%2FAlyn/lists"}