jhurliman

jhurliman / PNGImageHistogram / 0.1.2

README.md

Overview

Count pixel values and output RGBA + L (luminance) histograms with customizable (0-256) number of bins.

Usage

Input

ParameterDescription
input_fileData URI for a PNG image
bins(Optional) Number of histogram bins for each color channel. Clamped from [1-256], default is 256

Output

ParameterDescription
heightPixel height of the input image
widthPixel width of the input image
histogramsContains four arrays with keys r (red), g (green), b (blue), a (alpha), l (luminance). Arrays are the length of the bins input parameter (default 256)

Example

Input:

{
    "input_file":"data://jhurliman/jhurliman/4a.png",
    "bins":8
}

Output:

{
    "height": 412,
    "width": 438,
    "histograms": {
        "l": [0, 270, 1562, 844, 909, 1498, 48884, 126489],
        "r": [0, 270, 60, 1820, 1076, 12912, 23989, 140329],
        "g": [0, 1119, 969, 859, 805, 1239, 42939, 132526],
        "b": [0, 1331, 775, 1050, 6687, 14720, 56867, 99026],
        "a": [0, 0, 0, 0, 0, 0, 0, 180456]
    }
}