The routines in this library in general support image buffers with a sample type of byte, short (signed and unsigned), int (signed or unsigned), float and double, with any exceptions noted below. Images are handled using the image buffer protocol, which you should read about before using these procedures.
These functions compute statistics that have a scalar value per array of data. Each returns a list of real numbers, one per channel of the image buffer.
image-stats-max and image-stats-min return the maximum or minimum value in each channel of the image. image-stats-mean and image-stats-variance compute the mean and variance of all the samples in each channel of the image. image-stats-sum computes the sum of all the samples in each channel of the image, and image-stats-energy calculates the sum of the squares of all the samples.
image-stats-centroid finds the centroid of a region defined by a range of intensity values from low to high inclusive. The centroid location is returned, or Null if there are no pixels in the specified intensity range.
image-stats-2D-hist computes a two-dimensional histogram of two image buffers, usually two channels of a multi-channel (e.g. color) image. The histogram is built by examining each pixel in the images and incrementing the count of samples with [approximately] the same value in both channels. h-image should be the image containing the data to be plotted along the horizontal dimension of the histogram, and v-image should be the image for the vertical dimension.
The range of data being histogrammed is specified separately for each dimension in the function arguments. Each range is denoted by its starting value (min) and ending value (max) along the dimension, and the number of "bins", or partitions, to use. If data outside the range being histogrammed is encountered it is clipped to the closest value within the range and counted, instead of being discarded.
A one-channel byte-sampled image detailing the frequency in each bin is generated by dividing the histogram data by the scale factor hist-scale and clipping it to a 8-bit value. hist-outbuf should be the one-channel byte-sampled image where the histogram data will be placed. The dimensions of the image should be [h-bins v-bins].
Here is an example, taking the histogram of the red channel of an RGB image versus the green channel (are they REALLY dependent ?). 256 partitions along each axis are specified, giving 65,536 bins total:
(set hist-image (new-image c-byte 1 [256 256])) (image-stats-2D-hist (isolate-channel 0 image-buf) 256 0.0 255.0 (isolate-channel 1 image-buf) 256 0.0 255.0 4 hist-image)
The range of data being histogrammed is specified by a starting value (min), an ending value (max), and the number of "bins", or partitions, to use. If data outside the range being histogrammed is encountered it is clipped to the closest value within the range and counted, instead of being discarded.
Unlike the two-dimensional case, which returns an image buffer, these functions return an list of either integers or reals (depending on the function called) detailing the frequency in each bin.
image-stats-fast-hist is an optimized routine that computes a 256 bin histogram of a one-channel byte-sampled image and returns a list of integers.
Here is an example, taking the histogram of the red channel of an RGB image. 128 partitions are specified, with a range covering 0.0 to 255.0:
(image-stats-1D-hist-real (isolate-channel 0 image-buf) 256 0.0 255.0)
Scripts: | (load "image-stats.isis")
|
Libraries: | -lisis_stats
|
Headers: | isis_stats.h
|
Binders: | bind_stats_library(script);
|