salient-image
Simple salient processing on top of node-opencv
H. Xiaodi, H. Jonathan, C. Koch, Image signature: highlighting sparse salient regions, IEEE Transactions on Pattern Analysis and Machine Intelligence 34 (1) (2012) 194–200.
pre-requisites
installation
npm install salient-image
examples
Examples
Images
assets/input.jpg | assets/output.png | assets/output_with_options.png |
---|
| | |
Code
var salient = require("salient-image");
var cv = require("opencv");
salient("assets/mona.png", function(err, saliency){
var width = saliency.width(), height = saliency.height();
var imgOutput = new cv.Matrix(width, height, cv.Constants.CV_8U);
saliency.convertTo(imgOutput, cv.Constants.CV_8U, 255);
imgOutput.save("assets/output.png");
console.log('Image saved to ./assets/output.png');
});
Example with options
var cv = require("node-opencv");
salient("assets/mona.png", {
resize : [200, 200],
sigma : 0.045,
gaussianKernel : [11, 11]
}, function(err, saliency){
var width = saliency.width(), height = saliency.height();
var imgOutput = new cv.Matrix(width, height, cv.Constants.CV_8U);
saliency.convertTo(imgOutput, cv.Constants.CV_8U, 255);
imgOutput.save("assets/output_with_options.png");
console.log('Image saved to ./assets/output_with_options.png');
});
With existing opencv image as input
var img = new cv.Matrix(<...>);
salient({
image : img,
resize : [200, 200], // the resize size
sigma : 0.045, // the sigma of the gaussian kernel
gaussianKernel : [11, 11] // the size of the gaussian kernel
}, function(err, saliency){ ... });