# ndarray-warp

> ndarray image warping

Latest version **1.0.1** (published 2014-09-27) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.1 |
| Published | 2014-09-27 |
| First published | 2013-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | ndarray, image, volume, warp, coordinate, change, nonlinear, deform |

## Links

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

## Dependencies (2)

- [cwise](https://npm.io/package/cwise.md) ^1.0.4
- [ndarray-linear-interpolate](https://npm.io/package/ndarray-linear-interpolate.md) ^1.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-09-27
- 1.0.0 — 2014-09-22
- 0.1.1 — 2013-11-30
- 0.1.0 — 2013-06-26
- 0.0.0 — 2013-05-15

## README

ndarray-warp
============
Inverse [image warping](http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/warp/warp.pdf) operations for [ndarrays](https://github.com/mikolalysenko/ndarray).


Example
=======

```javascript
//Load input image
var lena = require("luminance")(require("lena"))

//Allocate storage for result
var result = require("zeros")([512, 512])

//Apply warp
require("ndarray-warp")(result, lena, function(out, inp) {
  var dx = inp[0] - 256
  var dy = inp[1] - 256
  var r  = Math.sqrt(dx * dx + dy * dy)
  var theta = Math.atan2(dy, dx)
  
  out[0] = 0.9 * r * Math.cos(theta + 0.01 * r) + 256
  out[1] = 0.7 * r * Math.sin(theta + 0.01 * r) + 256
})

//Save the result to stdout
require("save-pixels")(result, "png").pipe(process.stdout)
```

Which produces the following image:

<img src="https://raw.github.com/mikolalysenko/ndarray-warp/master/example/warp.png">

Install
=======

    npm install ndarray-warp
    
### `require("ndarray-warp")(output, input, map(out_coord, in_coord))`
Applies an inverse warp to an image

* `output` is an ndarray image that gets the result of applying the warp
* `input` is an ndarray iamge that is warped
* `map(result, coord)` is a mapping from the coordinates of out image to input image.

  + `result` gets the resulting coordinate in `input`
  + `coord` is the coordinate in `output`

# Credits
(c) 2013 Mikola Lysenko. MIT License

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