0.5.0 • Published 5 years ago

ndarray-imhist v0.5.0

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

ndarray-imhist

A package to plot grayscale images' histograms using node.js and Gnuplot, inspired by Matlab imhist command.

Installation

npm install ndarray-imhist

Gnuplot is required for this package to work. Make sure that it is installed and added to the path correctly by typing:

gnuplot --version

Usage

Syntax

imhist(img [, options]);
// or
let [x, y] = imhist(img [, options]);

displays the histogram of a grayscale image img (should be an ndarray) and return the historgram data as an array of two arrays containing x and y values respectively.

Options

Optionrequireddefaultdescription
channelno0Select the RGB channel to get the historgram for. 0 for the red channel, 1 for the green and 2 for the blue one. If img is a 2D array, this option has no effect.
colorno"blue"Set the impulses color, must be a valid Gnuplot "rgbcolor". Otherwise, plotting will fail silently
plotnotrueIf true, plot the histogram using Gnuplot. Otherwise, return just the histogram data.

Examples

const getPixels = require("get-pixels");
const imhist = require("ndarray-imhist");

getPixels("lena.png", function(err, pixels) {
  if(!err && pixels) {
    // show the image histogram
    imhist(pixels);

    // return the image histogram data without plotting it.
    let [x, y] = imhist(pixels, {plot: false});
    console.log(x, y);
  }
})

Here is how the histogram will look like:

ndarray-imhist

0.5.0

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago