stroke-width-transform

Stroke width transform

Usage no npm install needed!

<script type="module">
  import strokeWidthTransform from 'https://cdn.skypack.dev/stroke-width-transform';
</script>

README

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

  • Download the repo and it's submodules git clone --recursive https://github.com/image-js/stroke-width-transform.git.
  • Install emscripten.
  • Run emmake make over the root repo to compile the SWT.
  • Run npm run test to check if the compilation works.

API Documentation

License

BSD 3-clause License