-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathhistogram_match.js
More file actions
29 lines (27 loc) · 1.09 KB
/
Copy pathhistogram_match.js
File metadata and controls
29 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict";
var args = require('./commargs.js')(),
fs = require('fs'),
F = require('./filterwithcanvas.js'),
parallel = !!args.options['parallel'],
histogram_matcher = F.HistogramMatchFilter(F.MODE.RGB);
console.log('Loading..');
F.Image.load(__dirname+'/tint_target.jpg', function(target) {
var targetdata = target.getData();
histogram_matcher.cdf = [
F.Util.Filter.histogram(targetdata, F.CHANNEL.R, true, true).bin,
F.Util.Filter.histogram(targetdata, F.CHANNEL.G, true, true).bin,
F.Util.Filter.histogram(targetdata, F.CHANNEL.B, true, true).bin
];
F.Image.load(__dirname+'/source.jpg', function(img) {
console.log('Procesing..');
histogram_matcher.apply(img);
console.log('Saving..');
img.oCanvas.toPNG().then(function(png) {
fs.writeFile(__dirname+'/tint_source.png', png, function(err) {
if (err) console.log('error while saving image: ' + err.toString());
})
}).catch(function(err) {
console.log('error while saving image: ' + err.toString());
});
});
});