Documentation: Color Histogram

Description

This action determines the number of occurences of different color values used in the image, thereby creating a histogram. This action is similar to the "histogram" action, but creates a histogram for each channel, returning 3 arrays, one for each of the R, G and B channels. The histograms will be available in the returnValue object as shown in the example code. You can also choose to have the histograms painted on top of the image by using the paint parameter.

Demo



Example usage

var hist = {};	
var img = new Image();
img.onload = function() {
	Pixastic.process(img, "colorhistogram", {
		paint:true,returnValue:hist
	});
	hist.rvals; // <- array[255] red channel
	hist.gvals; // <- array[255] green channel
	hist.bvals; // <- array[255] blue channel
}
document.body.appendChild(img);
img.src = "myimage.jpg";

Parameters

  • paint (bool)
    If true, the histograms will be painted on the image
  • returnValue (array)
    An return value object which will hold the values (in the "values" property) of the histogram after execution.

View source: colorhistogram.js

Browser support