# ndarray-convolve

> Convolution and cross correlation functions for ndarrays

Latest version **2.0.0** (published 2015-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install ndarray-convolve
pnpm add ndarray-convolve
yarn add ndarray-convolve
bun add ndarray-convolve
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2015-05-03 |
| First published | 2013-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko, jaspervdg |
| Keywords | ndarray, convolve, correlate, fft, image, processing, filter, cross, kernel, blur |

## Links

- npm: https://www.npmjs.com/package/ndarray-convolve
- Repository: https://github.com/mikolalysenko/ndarray-convolve
- Issues: https://github.com/mikolalysenko/ndarray-convolve/issues
- npm.io page: https://npm.io/package/ndarray-convolve

## Dependencies (7)

- [cwise](https://npm.io/package/cwise.md) ^1.0.4
- [ndarray](https://npm.io/package/ndarray.md) ^1.0.15
- [bit-twiddle](https://npm.io/package/bit-twiddle.md) ^1.0.2
- [ndarray-fft](https://npm.io/package/ndarray-fft.md) ^1.0.0
- [ndarray-ops](https://npm.io/package/ndarray-ops.md) ^1.2.2
- [ndarray-complex](https://npm.io/package/ndarray-complex.md) ^1.0.1
- [typedarray-pool](https://npm.io/package/typedarray-pool.md) ^1.1.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2015-05-03
- 1.0.1 — 2014-09-27
- 1.0.0 — 2013-06-27
- 0.0.0 — 2013-05-21

## README

ndarray-convolve
================
[Convolutions](http://en.wikipedia.org/wiki/Convolution) and [cross correlations](http://en.wikipedia.org/wiki/Cross-correlation) on [ndarrays](https://github.com/mikolalysenko/ndarray).

## Example

```javascript
//Read in test image
var lena = require("luminance")(require("lena"))

//Generate a 5-point Laplace filter
var filter = require("ndarray-pack")([[0, 1, 0],
                                      [1, -4, 1],
                                      [0, 1, 0]])

//Convolve them together
require("ndarray-convolve")(lena, filter)
```

This produces the following array:

<img src="https://raw.github.com/mikolalysenko/ndarray-convolve/master/example/baboon_lap.png">


## Install

    npm install ndarray-convolve
    
## API

```javascript
var convolve = require("ndarray-convolve")
```

### `convolve( ... )`
Performs a convolution between two images with zero boundary conditions. As long as it does not cause unnecessary cropping, the kernel (`b`) will be assumed to have its origin in the center of the kernel (for even kernels, slightly to the right of the center, for example `[1,2,3,4]` would be assumed to have it origin at 3). There are four ways you can call this function:

#### `convolve(a, b)`
Convolves `a` and `b` storing the result in `a`

#### `convolve(out, a, b)`
Convolves `a` and `b` storing the result in `out`

#### `convolve(a_r, a_i, b_r, b_i)`
Convolves two complex arrays storing the result in `a_r, a_i`

#### `convolve(out_r, out_i, a_r, a_i, b_r, b_i)`
Convolves two complex array storing the result in `out_r, out_i`


### `convolve.wrap( ... )`
Convolves two arrays with periodic boundary conditions.  Same convention as `convolve`

### `convolve.correlate( ... )`
Cross correlates two arrays with zero boundary conditions.  Same convention.

### `convolve.correlate.wrap( ... )`
Cross correlates two arrays with wrapped boundary conditions.  Same convention again.

## Credits
(c) 2013 Mikola Lysenko. MIT License

---
_Source: https://npm.io/package/ndarray-convolve · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
