Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thibauts/ndarray-from-image
Extracts an image RGBA pixels as a ndarray
https://github.com/thibauts/ndarray-from-image
Last synced: 21 days ago
JSON representation
Extracts an image RGBA pixels as a ndarray
- Host: GitHub
- URL: https://github.com/thibauts/ndarray-from-image
- Owner: thibauts
- License: mit
- Created: 2015-09-27T09:02:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-27T09:05:26.000Z (about 9 years ago)
- Last Synced: 2024-11-17T07:21:02.408Z (about 1 month ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ndarray-from-image
==================
### Extracts an image RGBA pixels as a ndarrayExtracts an image RGBA pixels as a ndarray with shape `[width, height, 4]`. If a [dtype](https://github.com/shama/dtype) is provided as a second parameter, allocates a new typed array of the given type for use as the ndarray underlying data.
Install
-------```bash
$ npm install ndarray-from-image
```Usage
-----```javascript
var ndarrayFromImage = require('ndarray-from-image');var img = document.getElementById('img');
var arr = ndarrayFromImage(img/*, 'float32' */); // takes an optional dtype as a second parameter/*
arr now contains the canvas RGBA pixels as a ndarray
of shape [canvas.width, canvas.height, 4]
*/var value = arr.get(0, 0, 0); // will return the red value for the pixel of coordinates [0, 0].
```