Isis software documentation

Image Statistics

This library provides routines for measuring certain statistical properties of an image buffer, such as the mean or variance. Some histogramming functions are provided as well.

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.


Global Statistics

(image-stats-mean image) (image-stats-max image) (image-stats-min image) (image-stats-energy image) (image-stats-variance image) (image-stats-sum image)

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.


Centroids

(image-stats-centroid low high image)

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.


2D Histogramming

(image-stats-2D-hist h-image h-bins h-min h-max v-image v-bins v-min v-max hist-scale hist-outbuf)

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)

1D Histogramming

(image-stats-1D-hist-real image bins min max) (image-stats-1D-hist-integer image bins min max) (image-stats-fast-hist buf) # a fast 256 bin histogram of 1-channel byte-image These functions compute a one-dimensional histogram of an image. The histogram is built by taking each pixel in the images and incrementing the count of samples with [approximately] the same value.

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)


Requirements:
Scripts: (load "image-stats.isis")
Libraries: -lisis_stats
Headers: isis_stats.h
Binders: bind_stats_library(script);


Thanks to John Watlington for his contributions to this library.