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

blue-noise

v1.0.0

Published

Blue noise dithering for images

Readme

Blue Noise Dithering

A CLI to dither images with blue noise, and generate blue noise textures using the void-and-cluster algorithm.

Dithered profile image

What is Blue Noise?

Blue noise distributes pixels evenly, avoiding the clusters and voids of white noise and the repetitive patterns of Bayer dithering. The result is natural-looking dithered images that preserve detail without obvious artefacts.

Blue noise texture

64×64 tileable blue noise texture

Installation

npm install

Usage

# Basic usage
npm run dither <input-image>

# Custom colours
npm run dither <input-image> -- -f <foreground-hex> -b <background-hex>

Examples

# Black and white
npm run dither input/claude-shannon-mouse-mit-00.jpg

# Custom colours
npm run dither input/claude-shannon-mouse-mit-00.jpg -- -f "#ff0000" -b "#ffffff"

# Different noise texture
npm run dither input/claude-shannon-mouse-mit-00.jpg -- -n custom-noise.png

CLI Options

Dithering Command

  • <input> - Path to input image (required)
  • -o, --output <path> - Output directory (default: "output")
  • -n, --noise <path> - Path to blue noise texture (default: "./blue-noise.png")
  • -f, --foreground <hex> - Foreground colour in hex (default: "#000000")
  • -b, --background <hex> - Background colour in hex (default: "#ffffff")
  • -w, --width <pixels> - Resize image width
  • -h, --height <pixels> - Resize image height
  • -c, --contrast <value> - Adjust contrast (default: 1.0)

Generate Command

npm run start generate -- --size 64 --sigma 1.9 --verbose
  • -s, --size <pixels> - Texture size (8-512, default: 64)
  • --sigma <value> - Gaussian sigma (1.0-3.0, default: 1.9)
  • --seed <number> - Random seed for reproducibility
  • -v, --verbose - Show generation progress

How It Works

Each pixel in the input image is compared against the corresponding blue noise threshold value. If brighter than the threshold, use the background colour; if darker, use the foreground colour. The noise texture tiles seamlessly across the image.

Generating Blue Noise

Uses the void-and-cluster algorithm (Ulichney, 1993): identifies clusters and voids using Gaussian blur, then redistributes pixels until evenly spread. Each pixel gets a rank determining its threshold value.

The texture tiles seamlessly using torus topology. Power-of-two dimensions (64×64, 128×128) use FFT optimisation for ~50% faster generation.

Performance: 64×64 in ~2-5s, 128×128 in ~30-60s. Pre-generate textures for production use.

References

Additional Resources