Contours.ts
Extract contours & shapes from an image, for browsers and node.js.



Features
Approximate Contours to Common Shapes (Triangle, Rectangle, Square, Circle)
How to use
Install
using pckage manager:
npm i contours.ts
Or
add to your webpage:
<script src="unpkg.com/contours.ts"></script>
Or
download manually:
Contours.ts
Examples
Input Type
ContourFinder
expects image data (multi-channel image data is suported) in following format:
Get Contours
import { ContourFinder } from 'contours.ts'
const { contours } = new ContourFinder(imageData, {
blur: true,
threshold: 85,
})
console.log(contours)
Simplify Contours
import { ContourFinder } from 'contours.ts'
const { contours } = new ContourFinder(imageData).simplify(epsilon)
console.log(contours)
Approximate Shapes
import { ContourFinder } from 'contours.ts'
const { contours, shapeCollection } = new ContourFinder(imageData).approximate()
console.log(shapeCollection)
Contributions
Contirbutions are welcome, code is heavily commented and tests
are defined using jest
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Muhammad Ubaid Raza - @mubaidr - mubaidr@gmail.com
Acknowledgements
This project is heavily inspired by the these:
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!