warp and average images


0.2.23 years ago3 years agoMinified + gzip package size for @ismay/morpheus in KB



build status coverage status greenkeeper

warp and average images

This tool allows you to warp and average images. It does so by averaging the colors of each pixel. It accepts optional coordinates which it will use to morph all images to a common shape, for a more accurate result. It expects the images to be pngs of the same dimensions and the coordinates to be generated and exported with coordinator. You can use this library from the command line with morpheus-cli.


npm install -g @ismay/morpheus


So for example, to medoid average a collection of images without coordinates:

const fs = require('fs');
const globby = require('globby');
const savePixels = require('save-pixels');
const util = require('util');
const getPixels = util.promisify(require('get-pixels'));
const streamToPromise = require('stream-to-promise');
const morpheus = require('@ismay/morpheus');

const imagePaths = globby.sync(['images/*.png']);
const imagePromises = imagePaths.map(imagePath => getPixels(imagePath));

  .then(images => {
    const average = morpheus(images);
    return streamToPromise(savePixels(average, 'png'));
  .then(imageBuffer => {
    fs.writeFileSync('average.png', imageBuffer);


morpheus(images, [options]) ⇒ ndarray

Kind: global function Returns: ndarray - The average image

Param Type Description
images Array An array of ndarrays for the images
[options] Object Configuration options
[options.mean] Boolean Generate a mean average instead of a medoid average
[options.coordinates] Array An array of coordinate arrays



If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.