npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pyramids

v0.3.0

Published

Various kinds of (image) pyramids for ndarrays of arbitrary dimension.

Readme

Pyramids

Image pyramids give a (slightly) overcomplete multiscale representation of an image, based on a reduce operator that reduces the size of an image by a factor of two (note though that conventionally, level 0 is the original scale, and higher levels correspond to smaller sizes). Example usage:

var pyramid = require("pyramids")
var ndarray = require("ndarray")

var p = pyramid(ndarray(new Int32Array([11,10,6,12,3,2,15,9,4,5,14,7,13,8,1]), [3,5]), pyramid.adjunction)

The above computes a pyramid using erosion (local minima, in this case within each 2-by-2 block), of the following "image" (array):

The result is a list of ndarrays, with the first array (corresponding to level 0) being the original ndarray object. The array at level 1 is given by:

require("pyramids")(array, scheme[, maxlevel])

Returns a list containing array, followed by maxlevel (higher) levels of a pyramid based on the reduce operator of scheme (each an ndarray with the same type of data storage as array). If maxlevel is unspecified, it returns as many levels are necessary to end up with an array containing just one element. Note that the first level is simply the argument given to the function.

There is no restriction on the dimensionality of array, but a typed array must be used for storing the data in array (otherwise the pool allocator used internally will fail).

require("pyramids").detail(array, scheme[, maxlevel])

Same as require("pyramids"), but generates a detail pyramid. That is, all but the last level have been generated by expanding the next level and subtracting it from the current level.

require("pyramids").reconstruct(detailPyramid, scheme)

Reconstructs an image from a given detail pyramid (as output by the detail function). The reconstruction is done in-place. For example:

var pyramid = require("pyramids")
var p = pyramid.detail(ndarray(new Int32Array([11,10,6,12,3,2,15,9,4,5,14,7,13,8,1]), [3,5]), pyramid.adjunction)
// do something with the detail pyramid
pyramid.reconstruct(p, pyramid.adjunction)
// p now contains a normal pyramid (with the first level corresponding to the full resolution reconstructed image)

Morphological pyramids

Non-linear pyramids based on reduce and expand operators that satisfy the so-called pyramid condition: first expanding an image and then reducing it recovers the original image.

require("pyramids").adjunction

The adjunction pyramid has a reduce operator based on erosion, as described in

Nonlinear multiresolution signal decomposition schemes — Part I: Morphological pyramids ''IEEE Transactions on Image Processing'', Vol. 9, No. 11. (November 2000), pp. 1862-1876, doi:10.1109/83.877209 by John Goutsias, Henk J. A. M. Heijmans.

The structuring element used here is a (flat) 2-by-2 square in 2D, and in general a hypercube with sides of length 2. The expand operator uses the dilation that forms an adjunction with the erosion.

require("pyramids").SunMaragos

The SunMaragos pyramid has an opening (rather than an erosion) as reduce operator. The same structuring element is used as in the adjunction pyramid, based on the results in

A New Class of Morphological Pyramids for Multiresolution Image Analysis In Geometry, Morphology, and Computational Imaging, Vol. 2616 (2003), pp. 165-175, doi:10.1007/3-540-36586-9_11 by Jos B. T. M. Roerdink edited by Tetsuo Asano, Reinhard Klette, Christian Ronse.

This pyramid tends to preserve more of the image than the adjunction pyramid. However, the same expand operator is used as for the adjunction pyramid. Note that (according to Goutsias and Heijmans, 2000) Sun and Maragos originally used a different structuring element (of length 3).

Linear pyramids

Non-linear pyramids based on reduce and expand operators that satisfy the so-called pyramid condition: first expanding an image and then reducing it recovers the original image.

require("pyramids").binomial

This is a very basic pyramid that is not ideal for all purposes. However, it is essentially equivalent to the traditional Gaussian pyramid, and the Laplacian pyramid if a detail pyramid is computed. It uses a binomial filter ([1,4,6,4,1]/16) with the reduce and expand operators defined here:

The Laplacian Pyramid as a Compact Image Code ''IEEE Transactions on Communications'', Vol. 31, No. 4. (April 1983), pp. 532-540, doi:10.1109/tcom.1983.1095851 by Peter J. Burt, Edward H. Adelson