image-js / stroke-width-transform

BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

stroke-width-transform

NPM version build status npm download

Stroke Width Transform for detecting text on images using CCV library and it's Javascript bindings.

Installation

$ npm install --save stroke-width-transform

Usage

import strokeWidthTransform from 'stroke-width-transform';
import Image from 'image-js';

const swtOptions = {
  interval: 1,
  minNeighbors: 1,
  scaleInvariant: true,
  direction: 0,
  sameWordThresh: [0.1, 0.8],
  size: 3,
  lowThresh: 124,
  highThresh: 204,
  maxHeight: 300,
  minHeight: 8,
  minArea: 38,
  letterOccludeThresh: 3,
  aspectRatio: 8,
  stdRatio: 0.83,
  thicknessRatio: 1.5,
  heightRatio: 1.7,
  intensityThresh: 31,
  distanceRatio: 2.9,
  intersectRatio: 1.3,
  elongateRatio: 1.9,
  letterThresh: 3,
  breakdown: 1,
  breakdownRatio: 1 
};

Image.load('myImage.png').then((image) => {
  var rois = strokeWidthTransform(image, swtOptions); // rois contains the regions with text
})
Sample input Image with ROI's

Install it from source

API Documentation

License

BSD 3-clause License