Created
August 15, 2013 22:16
-
-
Save tmcw/6245471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var queue = require('queue-async'); | |
var glob = require('glob'); | |
var cwise = require('cwise'); | |
var ndarray = require('ndarray'); | |
var getPixels = require('get-pixels'); | |
var savePixels = require('save-pixels'); | |
var q = queue(10); | |
['data/20130815_1658.png', | |
'data/20130815_1738.png', | |
'data/20130815_1718.png' | |
].forEach(function(f) { | |
q.defer(getPixels, f); | |
}); | |
var justGrey = cwise({ | |
args: ["array", "index", "array", "array", "array"], | |
body: function grey(out, i, r, g, b) { | |
if (i % 3 == 0) out = r | |
else if (i % 3 == 1) out = g | |
else if (i % 3 == 2) out = b | |
else out = 255 | |
} | |
}); | |
q.awaitAll(function(err, results) { | |
var a = results[0], | |
b = results[1], | |
c = results[2]; | |
var in_shape = a.shape.slice(0); | |
var result = ndarray(new Uint8Array(a.size), in_shape); | |
justGrey(result, a.pick(undefined, undefined, 0), b.pick(undefined, undefined, 1), c.pick(undefined, undefined, 2)); | |
savePixels(result, 'png').pipe(process.stdout); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment