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

rle-components

v0.0.3

Published

Connected component labeling / extraction for narrowband level sets

Readme

rle-components

Connected component labelling for narrowband level sets. It is part of the rle-* collection of libraries for processing narrow band level sets.

Usage/Installation

First, install the package using npm:

npm install rle-components

Then you can use the library to split a level set into its connected components. For example:

//First create a volume
var volume = require("rle-sample").solid.dense([-32, -32, -32], [32, 32, 32], function(x) {
  var s = Math.sin(x[0]) + Math.sin(x[1]) + Math.sin(x[2]);
  var b = Math.max(Math.abs(x[0]), Math.abs(x[1]), Math.abs(x[2]));
  return Math.max(s + 2.2, b - 9.9);
});

//Then split into separate components
var components = require("rle-components").split(volume);

Here is the result:

You can try out a demo in your browser.

require("rle-components").label(volume[, link_func, solid_func])

This takes a narrowband level set as input and assigns labels to the components.

  • volume is the level set we are labelling
  • link_func(a,b) determines if two phases should be considered linked in the same component. By default, always returns true.
  • solid_func(a) determines if a phase should be included in the components. By default, returns false for phase 0.

The result of calling the function is a labelStruct object which has the following properties:

  • count The number of connected components
  • labels An array of integers of length = volume.length() which gives the name of the connected component, starting at 0. Not solid components are labeled -1.

require("rle-components").split(volume[, labelStruct])

This splits a volume into a collection of volumes with different connected components.

  • volume is the volume to split
  • labelStruct (Optional) is the result of calling label() (see above) on the volume. If not specified, label is called with the default arguments.

Returns an array of of volumes representing the different connected components of volume

Credits

(c) 2013 Mikola Lysenko. BSD