Quickly make a poster from an ndarray image. Provide your own colors even.
npm install posterize
var getPixels = ;var savePixels = ;var fs = ;var posterize = ;
posterize(pixels, colors, ?sort)
This is an ndarray with a shape of
[x, y, 3] or
[x, y, 4]. Posterize only works on the rgb channels and clones the alpha channel if present.
This is either a
number greater than zero or an array of rgb objects. If it is a number
posterize will create colors based on its color reducing process. If its an array, the length of the array will determine the number of colors and the values will be used when setting the new images pixels.
an rgb object looks like:
sort (not required)
This is a non required boolean the defaults to true.
colors is an array,
sort can be passed to force
posterize to resort the passed color array or not. If
sort is true
posterize will resort the provided colors to match color order of the poserized image.