Giter Club home page Giter Club logo

deslantimg's Introduction

Deslanting Algorithm

  • Update 2021/2: added Python package
  • Update 2021/1: added Python implementation

This algorithm sets handwritten text in images upright, i.e. it removes the cursive writing style. One can use it as a preprocessing step for handwritten text recognition. The following illustration shows input and output of the algorithm for a given image (data/test1.png).

deslanting

There are three implementations provided (Python, C++, OpenCL) with a focus on the Python implementation. For C++ and OpenCL see the folder extras.

Installation

  • Go to the root level of the repository
  • Install by running pip install .
  • Run deslant_img (without arguments) from the command line to process the images in the data directory (images taken from IAM and Bentham dataset)
  • This opens a window showing the input image, deslanted image and score values
  • The script can be configured via command line, see available options below, or by running deslant_img -h

plot

Usage

Command line options of deslant_img:

usage: deslant_img [-h] [--data DATA] [--optim_algo {grid,powell}]
                   [--lower_bound LO] [--upper_bound HI]
                   [--num_steps STEPS] [--bg_color BG]

optional arguments:
  -h, --help            show this help message and exit
  --data DATA           directory containing the (.png|.jpg|.bmp) input images
  --optim_algo {grid,powell}
                        either do grid search, or apply Powell's derivative-
                        free optimizer
  --lower_bound LO      lower bound of shear values
  --upper_bound HI      upper bound of shear values
  --num_steps STEPS     if grid search is used, this argument defines the
                        number if grid points
  --bg_color BG         color to fill the gaps of the sheared image that is
                        returned

API

  • Import the deslant_img function as shown in the code snippet
  • For documentation of parameters see command line parameters above or use help(deslant_img)
from deslant_img import deslant_img
import cv2
import matplotlib.pyplot as plt

img = cv2.imread('data/test1.png', cv2.IMREAD_GRAYSCALE)
res = deslant_img(img)

plt.imshow(res.img)
plt.show()

Algorithm

Vinciarelli and Luettin describe the algorithm in their 2001 paper. Here is a short outline of the algorithm:

algo

deslantimg's People

Contributors

bertsky avatar githubharald avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.