Computing Image Statistics
EasyObject statistics are related to the objects in an image.
The average and standard deviation of gray-level values can be computed in a sliding window, i.e., computed for every position of a rectangular window centered on every pixel. The window size is arbitrary.
The computing time of these functions does not depend on the window size.
The result of the operation is another image.
The local average, EasyImage::.LocalAverage, corresponds to a strong low-pass filtering.
Sliding window average
The local standard deviation, EasyImage::.LocalDeviation enhances the regions with a high frequency contents, such as noisy or textured areas.
Sliding window standard deviation
A histogram is a statistical summary of an image: it shows the number of occurrences of every gray-level value in an image, and it's shape reveals characteristics of the image. For instance, peaks in the histogram curve correspond to dominant colors in the image. If the histogram is bi-modal, a large peak for the dark values corresponding to the background, and smaller peaks in the light values.
Typical image histogram
Histogram Computation
EasyImage::.Histogram computes the histogram of an image. It can take a flexible mask as input argument.
BW8, BW16 and BW32 source images are supported.
You can compute the cumulative histogram of an image, i.e. the count of pixels below a given threshold value, by calling EasyImage::.CumulateHistogram after EasyImage::.Histogram.
Histogram Analysis
EasyImage::.AnalyseHistogram and
EasyImage::.AnalyseHistogramBW16 provide statistics and thresholding values:
- Total number of pixels.
- Smallest and largest pixel value (gray-level range).
- Average and standard deviation of the pixel values.
- Value and frequency of the most frequent pixel.
- Value and frequency of the least frequent pixel.
EasyImage::.Equalize re-maps the gray levels so that the histogram fills in the whole dynamic range as uniformly as possible.
This may be useful to maximize image contrast, or reveal a lot of image details in dark areas.
Equalized image and histogram
Setup a lookup table
EasyImage::.SetupEqualize creates a LUT so you can work explicitly with the histogram and LUT vectors. It can be more efficient to keep the image histogram for other purposes (i.e statistics) and keep the equalization LUT to apply to other images.
Equalization lookup table
EasyImage::.Focusing computes the total gradient energy of the image. You can then use this gradient as a measure of the focusing of an image.
The gradients of the image show the edges of the structures present in the image, with strong values if the image is well-focused and weaker values otherwise.
To compute the total gradient energy of the image, Open eVision:
a. | Squares the pixel values of the horizontal and vertical gradient images. |
b. | Averages the squared pixel values over both images. |
c. | Sums the averages. |
d. | Takes the square root of the resulting value. |
The resulting value is maximum if the image is well-focused.
A well-focused image, with its (absolute-valued) horizontal and vertical gradients.
The gradients show the edges of the structures with strong values. The total gradient energy for this image is 17.9.
A badly focused image, with its (absolute-valued) horizontal and vertical gradients.
The gradients show the edges of the structures with weak values. The total gradient energy for this image is 7.9.
- EasyImage::.Area counts pixels with values above (or on) a threshold.
- EasyImage::.AreaDoubleThreshold counts pixels whose values are comprised between (or on) two thresholds.
- EasyImage::.BinaryMoments computes the 0th, 1st or 2nd order moments on a binarized image, i.e. with a unit weight for those pixels with a value above or equal to the threshold, and zero otherwise. It provides information such as object position and extent.
-
EasyImage::.WeightedMoments computes the 0th, 1st, 2nd, 3rd or 4th order weighted moments on a gray-level image. The weight of a pixel is its gray-level value. It provides information such as object position and extent.
- EasyImage::.GravityCenter computes the coordinates of the gravity center of an image, i.e. the average coordinates of the pixels above (or on) the threshold.
- EasyImage::.PixelCount counts the pixels in the three value classes separated by two thresholds.
- EasyImage::.PixelMax computes the maximum gray-level value in an image.
- EasyImage::.PixelMin computes the minimum gray-level value in an image.
- EasyImage::.PixelAverage computes the average pixel value in a gray-level or color image. For a color image, it computes the means of the three pixel color components, the variances of the components and the covariances between pairs of components.
- EasyImage::.PixelStat computes min, max and average gray-level values.
- EasyImage::.PixelVariance computes average and variance of pixel values.
- EasyImage::.PixelStdDev computes average and standard deviation of pixel values. For a color image, it computes the standard deviations and correlation coefficients (covariance over the product of standard deviations) of the pairs of pixel component values.
- EasyImage::.PixelCompare counts the number of different pixels between two images.