@ismay/morpheus

    0.2.2 • Public • Published

    morpheus

    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.

    Installation

    npm install -g @ismay/morpheus

    Example

    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));
     
    Promise.all(imagePromises)
      .then(images => {
        const average = morpheus(images);
        return streamToPromise(savePixels(average, 'png'));
      })
      .then(imageBuffer => {
        fs.writeFileSync('average.png', imageBuffer);
      });

    Usage

    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

    License

    MIT

    Keywords

    none

    Install

    npm i @ismay/morpheus

    DownloadsWeekly Downloads

    10

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    51.1 kB

    Total Files

    36

    Last publish

    Collaborators

    • avatar