Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/ball-morphology
Morphological operations with ball shaped structuring elements
https://github.com/mikolalysenko/ball-morphology
Last synced: about 2 months ago
JSON representation
Morphological operations with ball shaped structuring elements
- Host: GitHub
- URL: https://github.com/mikolalysenko/ball-morphology
- Owner: mikolalysenko
- License: mit
- Created: 2013-05-21T18:00:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-27T21:31:16.000Z (over 11 years ago)
- Last Synced: 2024-10-19T00:19:25.884Z (2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 8
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ball-morphology
===============
[Mathematical morphology](http://en.wikipedia.org/wiki/Mathematical_morphology) for [ndarrays](https://github.com/mikolalysenko/ndarray) where the structuring element is a ball in some [Lp metric](https://en.wikipedia.org/wiki/Lp_space).# Example
First, let's read an image:
```javascript
var morphology = require("ball-morphology")require("get-pixels")("bwimage.png", function(err, data) {
var r = data.pick(-1, -1, 0)
// ... do stuff ...
})
```Which gives us the following array:
We can dilate the image using the following command:
```javascript
morphology.dilate(r, 1)
```Which produces the following result:
Similarly, we can also perform an erosion:
```javascript
morphology.erode(r, 1)
```Giving the result:
For convenience, openings and closing are also implemented:
```javascript
morphology.open(r, 1)
morphology.close(r, 1)
```## Install
npm install ball-morphology
## API```javascript
var morphology = require("ball-morphology")
```### `morphology.dilate(array, radius[, p])`
Performs a binary morphological [dilation](http://en.wikipedia.org/wiki/Dilation_%28morphology%29) with an Lp ball of a given radius* `array` is a binary image (updated in place)
* `radius` is the radius of the ball in pixel units (may be fractional)
* `p` is an optional argument giving the exponent of the metric. (Default 2)**Returns** `array`
### `morphology.erode(array, radius[, p])`
Performs a binary morphological [erosion](http://en.wikipedia.org/wiki/Erosion_%28morphology%29) with an Lp ball of a given radius* `array` is a binary image (updated in place)
* `radius` is the radius of the ball in pixel units (may be fractional)
* `p` is an optional argument giving the exponent of the metric. (Default 2)**Returns** `array`
### `morphology.open(array, radius[, p])`
Performs a binary morphological [opening](http://en.wikipedia.org/wiki/Opening_%28morphology%29) with an Lp ball of a given radius* `array` is a binary image (updated in place)
* `radius` is the radius of the ball in pixel units (may be fractional)
* `p` is an optional argument giving the exponent of the metric. (Default 2)**Returns** `array`
### `morphology.close(array, radius[, p])`
Performs a binary morphological [closing](http://en.wikipedia.org/wiki/Closing_%28morphology%29) with an Lp ball of a given radius* `array` is a binary image (updated in place)
* `radius` is the radius of the ball in pixel units (may be fractional)
* `p` is an optional argument giving the exponent of the metric. (Default 2)**Returns** `array`
# Credits
(c) 2013 Mikola Lysenko. MIT License