HISTOGRAM: Display a Histogram of Image Pixel Values

Form: HISTOGRAM source [BOX=b] [NOLOG] [BIN=n] [XMIN=x1] [XMAX=x2]
 $$
[YMIN=y1] [YMAX=y2] [HARD] [WIND=n] [BUF=buf]
 $$
[NOERASE] [PORT]
source
specifies the image.
BOX=b
limits the computation to those pixels in box 'b'.
NOLOG
displays the number of pixels at each intensity, rather than the logarithm.
BIN=n
bins the image values by the specified factor.
XMIN, XMAX
limits the computation to those pixels with values between x1 and x2, inclusive.
YMIN, YMAX
limits the display of the histogram on the Y-axis to be from y1 to y2.
HARD
sends the plot to the hardcopy device.
WIND=n
put the plot in window n of a 2x2 grid
BUF=buf
load the histogram data into image buffer 'buf'
NOERASE
don't erase screen before plotting.
PORT
make hardcopy output in portrait mode (default: landscape)

This program displays a histogram of an image, plotting the logarithm of the number of pixels at each value for the image 'source'.

Use the BIN word to specify how wide the intensity intervals show in the plot is to be. Normally the binning factor is 1, meaning that the plot displayed is the logarithm of the number of pixel values at each intensity (the image values are converted to integers). If the bin factor is non-zero, the display is the log of the number in larger bins. For example, if the bin was 5, and the minimum value in the image is 0, then the plot shows the number of pixels with intensity 0 - 4, 5 - 9, 10 - 14, 15 - 19, etc. If there is a large range in intensities, the BIN word should be used to keep the plot from having so many points that it looks like hash. If the number of points in the histogram is larger than 2048, the program will increase the bin size to reduce the number of points in the plot.

The BOX word limits the calculation to those pixels in the specified box. The XMIN and XMAX words limit the calculation to those pixels in the specified intensity range. If XMIN is not given, the lower limit will be the minimum pixel value in the image. If XMAX is not given, the upper limit will be the maximum pixel value in the image.

The YMIN and YMAX words, by contrast, limit the DISPLAY of the histogram so that the Y-axis runs over the given range. These words do not change the calculation in any way. If YMIN is not used, the lower limit of the display will be the smallest number of pixels in the image that have a given value (often this is zero pixels at many intensities). If YMAX is not used, the upper limit of the display will be the largest number of pixels which have a certain intensity.

NOLOG makes the plot show the actual number of pixels at each intensity, rather than the logarithm. When the logarithm is computed in the default option, intensities with no pixels are given the value 0, so you cannot distinguish an intensity with 1 pixel and an intensity with 0 pixels unless you use the NOLOG word.

The NOERASE keyword suppresses the erasure of the screen before plotting. Up to 4 histograms may be plotted on a single output page using the WIND=n keyword, where n=(1,2,3,4), with windows numbered from left-to-right, bottom-to-top in the conventional MONGO order. Hardcopy is flushed to the printer only after WIND=4 is used. The plot may be printed in portrait mode (long axis of the paper vertical) using the PORT keyword.

The histogram for an image may be loaded into an image buffer as a "spectrum" (1-D image) for further analysis or storage for use with external programs using the BUF=buf keyword.

Examples:

HISTOGRAM 4
Shows the histogram for image 4
HISTOGRAM $Q BOX=3
Shows the histogram for image Q (where Q is a variable) using only the pixels in box 3
HISTOGRAM 2 XMIN=1000 XMAX=1999
Shows the log of number of pixels with values between 1000 and 1999.
HISTOGRAM 4 NOLOG
Shows the number of pixels (not the log) at each value in image 4.
HISTOGRAM 3 HARD
computes a histogram for image 3, sending it to hardcopy printer.
HISTOGRAM 2 XMIN=1000 XMAX=1999 BUF=10
same as #3 above, except that instead of plotting the histogram, it is loaded into image buffer 10 as a spectrum.