An open API service indexing awesome lists of open source software.

https://github.com/image-js/canny-edge-detector

JavaScript implementation of the Canny edge detector
https://github.com/image-js/canny-edge-detector

Last synced: about 1 year ago
JSON representation

JavaScript implementation of the Canny edge detector

Awesome Lists containing this project

README

          

# canny-edge-detector

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![npm download][download-image]][download-url]

Canny edge detector

## Installation

`$ npm install canny-edge-detector image-js`

## Usage

### cannyEdgeDetector(image[, options])

Find edges in an image using the [Canny algorithm](https://en.wikipedia.org/wiki/Canny_edge_detector).
Returns a greyscale image with the edges at `options.brightness` value.

__arguments__

* `image` - a greyscale Image
* `options` - an optional object

__options__

* `lowThreshold`: Low threshold for the hysteresis procedure (default: 10).
* `highThreshold`: High threshold for the hysteresis procedure (default: 30).
* `gaussianBlur`: Sigma parameter for the gaussian filter step (default: 1.1).
* `brightness`: Values assigned to each edge pixel on the result image (default: image.maxValue).

## Example
```js
const cannyEdgeDetector = require('canny-edge-detector');
const Image = require('image-js').Image;

Image.load('my-image.png').then((img) => {
const grey = img.grey();
const edge = cannyEdgeDetector(grey);
return edge.save('edge.png');
})
```

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/canny-edge-detector.svg?style=flat-square
[npm-url]: https://npmjs.org/package/canny-edge-detector
[travis-image]: https://img.shields.io/travis/image-js/canny-edge-detector/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/image-js/canny-edge-detector
[download-image]: https://img.shields.io/npm/dm/canny-edge-detector.svg?style=flat-square
[download-url]: https://npmjs.org/package/canny-edge-detector