All Projects → kakul → Alyn

kakul / Alyn

Licence: mit
Detect and fix skew in images containing text

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Alyn

Machine Learning Projects
This repository consists of all my Machine Learning Projects.
Stars: ✭ 135 (-33.17%)
Mutual labels:  numpy, matplotlib
Python Novice Inflammation
Programming with Python
Stars: ✭ 199 (-1.49%)
Mutual labels:  numpy, matplotlib
Ml Cheatsheet
A constantly updated python machine learning cheatsheet
Stars: ✭ 136 (-32.67%)
Mutual labels:  numpy, matplotlib
Data Science For Marketing Analytics
Achieve your marketing goals with the data analytics power of Python
Stars: ✭ 127 (-37.13%)
Mutual labels:  numpy, matplotlib
Scientific Visualization Book
An open access book on scientific visualization using python and matplotlib
Stars: ✭ 6,336 (+3036.63%)
Mutual labels:  matplotlib, numpy
Color Tracker
Color tracking with OpenCV
Stars: ✭ 128 (-36.63%)
Mutual labels:  numpy, image-processing
Opendatawrangling
공공데이터 분석
Stars: ✭ 148 (-26.73%)
Mutual labels:  numpy, matplotlib
Pythonstudy
Python related technologies used in work: crawler, data analysis, timing tasks, RPC, page parsing, decorator, built-in functions, Python objects, multi-threading, multi-process, asynchronous, redis, mongodb, mysql, openstack, etc.
Stars: ✭ 103 (-49.01%)
Mutual labels:  numpy, matplotlib
Gasyori100knock
image processing codes to understand algorithm
Stars: ✭ 1,988 (+884.16%)
Mutual labels:  numpy, image-processing
Color recognition
🎨 Color recognition & classification & detection on webcam stream / on video / on single image using K-Nearest Neighbors (KNN) is trained with color histogram features by OpenCV.
Stars: ✭ 154 (-23.76%)
Mutual labels:  numpy, image-processing
Pybotics
The Python Toolbox for Robotics
Stars: ✭ 192 (-4.95%)
Mutual labels:  numpy, pypi
Tftb
A Python module for time-frequency analysis
Stars: ✭ 185 (-8.42%)
Mutual labels:  numpy, matplotlib
Stock Market Analysis And Prediction
Stock Market Analysis and Prediction is the project on technical analysis, visualization and prediction using data provided by Google Finance.
Stars: ✭ 112 (-44.55%)
Mutual labels:  numpy, matplotlib
Ds Ai Tech Notes
📖 [译] 数据科学和人工智能技术笔记
Stars: ✭ 131 (-35.15%)
Mutual labels:  numpy, matplotlib
Boxdetection
A Box detection algorithm for any image containing boxes.
Stars: ✭ 104 (-48.51%)
Mutual labels:  numpy, image-processing
Data Analysis
主要是爬虫与数据分析项目总结,外加建模与机器学习,模型的评估。
Stars: ✭ 142 (-29.7%)
Mutual labels:  numpy, matplotlib
Double pendulum
Animations of random double pendulums
Stars: ✭ 73 (-63.86%)
Mutual labels:  numpy, matplotlib
Connected Components 3d
Connected components on multilabel 3D & 2D images. Handles 26, 18, and 6 connected variants.
Stars: ✭ 90 (-55.45%)
Mutual labels:  numpy, image-processing
Machine Learning With Python
Practice and tutorial-style notebooks covering wide variety of machine learning techniques
Stars: ✭ 2,197 (+987.62%)
Mutual labels:  numpy, matplotlib
Data Science Types
Mypy stubs, i.e., type information, for numpy, pandas and matplotlib
Stars: ✭ 180 (-10.89%)
Mutual labels:  numpy, matplotlib

Alyn

PyPI version

Skew detection and correction in images containing text

Image with skew
Image after deskew

Install and use via pip!

Recommended way(using virtualenv):

  1. mkdir alyn-test
  2. cd alyn test
  3. mkvirtualenv .
  4. pip install alyn
  5. source bin/activate

To detect skew angle in image:

from alyn import SkewDetect
sd = SkewDetect(
	input_file='path_to_file',
	batch_path='optional_batch_processing_path',
	output_file='optional_text_file_output_path',
	display_output='Yes/No')
sd.run()
Extra options:
  • sigma:canny edge detection blurring
  • plot_hough: display hough lines detected
  • num_peaks: control the number of hough line peaks

To deskew image:

from alyn import Deskew
d = Deskew(
	input_file='path_to_file',
	display_image='preview the image on screen',
	output_file='path_for_deskewed image',
	r_angle='offest_angle_in_degrees_to_control_orientation')`
d.run()

Requires

  • numpy
  • matplotlib
  • scipy
  • scikit-image

Techniques used

  • Canny Edge Detection
  • Hough Transform

Features

  • Detect the skew in given images
  • Display the output
  • Save the output to txt file
  • Batch process files in a directory
  • View Hough Transform of a given image
  • Set the number of peaks for Hough Transform and Sigma for Canny Edge detection
  • Rotate the image to remove the skew

How the skew detection works

The skew detection script takes image file as input, then performs the following steps:

  • Converts the image to greyscale
  • Performs Canny Edge Detection on the Image
  • Calculates the Hough Transform values
  • Determines the peaks
  • Determines the deviation of each peaks from 45 degree angle
  • Segregates the detected peaks into bins
  • Chooses the probable skew angle using the value in the bins

The deskew script uses the skew angle determined using skew detection script to remove the skew from the image.

Using scripts directly(older method)

Image skew calculation using skew_detect.py

To calculate the skew angle for a given image file, use -i option followed by the path to file:

./skew_detect.py -i image.jpg

To save output in a text file add -o option followed by the output file name:

./skew_detect.py -i image.jpg -o output.txt

To display output information add -d option followed by a string Yes:

./skew_detect.py -i image.jpg -d Yes

To batch process files in a directory, use -b option followed by the path to directory:

./skew_detect.py  -b examples

To display Hough Transform plot for an image,:

./skew_detect.py -i image.jpg -p Yes
Output of the Hough Transform:

To set the value of sigma for Gaussian blurring in Canny Edge Detection, use -s option followed by the desired value:

./skew_detect.py -i image.jpg -s 3

To set the number of peaks collected from Hough Transform, use -n option followed by the desired value:

./skew_detect.py -i image.jpg -n 10

Image Deskew using deskew.py

To perform a simple deskew and display the output:

./deskew.py -i image.jpg -d Yes

To save the deskewed image, use the following:

./deskew.py -i image.jpg -o rotated.jpg

In 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:

./deskew.py -i image.jpg -o rotated.jpg -r 90

To 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].