Histogram

Function This analysis tool examines an image and graphs the occurence per channel of each value. The X axis of the Histogram corresponds to the numerical value of a pixel. The Y axis is the percentage of pixels per channel that have that value. The graph has nothing to do with the input pixel's original X or Y position in the image.

Here are some examples:

Example 1

A 256x256 8-bit black and white Ramp. Since we have equal amounts of the entire range of pixels, we get a solid white field. The orientation of the ramp has no bearing on the graph:

Example 2

A 256x256 8-bit (ugly) Color. Since the color is set to (about) .75 .5 .25, each channel exists at only one position in the Histogram:

Example 3

A 256x256 8-bit 4-corner Grad. Red's four corner values are: (1, .5, .5, .5), Green's are (0, 1, .5, .5), and Blue's are (.5, 0, 0, 0). This reflects that most of Red's value are around .5, ramping downwards to 1, and no value less than .5. In the Viewer, you can toggle through the different channels by hitting R, G, B, or C in that Viewer.

Example 4

We now add a Brightness of 2 in between the Grad and the Histogram. We have also toggled on the Histogram parameter of maxPerChannel to see our results better. The result (the image is zoomed in here) is that we have no odd values (all numbers are multiplied by 2), so we have a gap at every other value. It is a tell-tale sign of digital alteration when you see such regular patterns in a histogram.

 

Parameters
Type
Defaults
Function
width, height
int
512, 512 The width and height of the Histogram. You probably want to set the width to 256 on an 8-bit image to get 1-to-1 correspondence.
ignore
int
0

Tells Shake to ignore black or white pixels. For example, if you have a small element on a large black background, your histogram will be skewed towards black. Toggle off black consideration to better analyze the image.

0 = no ignore
1 = ignore values of 0
2 = ignore values of 1
3 = ignore values of 0 and 1

maxPerChannel
int
0

This toggles how the graph channels relate to each other. If you have a large red component, and a small blue component, the blue will be very short, making it difficult to see. Toggle this to view the blue channel in relation to itself, rather than the red:

0 = distribution of values relative to RGB total
1 = distribution of values relative to its own channel.


Synopsis

image Histogram( image, 
  int width, 
  int height, 
  int ignore, 
  int maxPerChannel 
);


Script

image = Histogram(image, width, height, ignore, maxPerChannel);


Command Line

shake -histogram width height ignore maxPerChannel 


See Also
PlotScanline