0.1.0 • Published 2 years ago

threshold-image-data v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Threshold Image Data

Apply black/white threshold to a decoded raw image, using the Rec. 709 luma algorithm.

Should match ImageMagick's threshold operation.

Installation

npm install --save threshold-image-data

Usage

const thresholdImageData = require('threshold-image-data')

// Modifies the image in-place
thresholdImageData(image, 0.5)

API

thresholdImageData(image, threshold)

Apply the threshold to the image.

The image argument should be a ImageData instance, or any object with the following properties:

  • width: Number - The width of the image, in pixels
  • height: Number - The height of the image, in pixels
  • data: Buffer | TypedArray - The image data, stored as raw pixel data in the RGBA order

The image will be modified in-place.

Related

0.1.0

2 years ago